/// Serializes a `MetaPackage` to json.
///
/// # Examples
/// ```
/// # use fuchsia_pkg::MetaPackage;
/// let meta_package = MetaPackage::from_name("package-name".parse().unwrap());
/// let mut v: Vec<u8> = vec![];
/// meta_package.serialize(&mut v).unwrap();
/// assert_eq!(std::str::from_utf8(v.as_slice()).unwrap(),
///            r#"{"name":"package-name","version":"0"}"#);
/// ```
Serializes a `MetaPackage` to json.
Serializes a ` MetaPackage ` to json .
pub fn serialize(&self, writer: impl io::Write) -> Result<(), MetaPackageError> {
        serde_json::to_writer(
            writer,
            &MetaPackageV0Serialize { name: self.name.as_ref(), variant: self.variant.as_ref() },
        )?;
        Ok(())
    }
pub fn serialize ( & self , writer : impl io :: Write ) -> Result < ( ) , MetaPackageError > { serde_json :: to_writer ( writer , & MetaPackageV0Serialize { name : self . name . as_ref ( ) , variant : self . variant . as_ref ( ) } , ) ? ; Ok ( ( ) ) }
Serializes a `MetaPackage` to json.
Serializes a ` MetaPackage ` to json .
&self
writer
impl io::Write
examples
None
use fuchsia_pkg::metapackage;
let meta_package = MetaPackage::from_name("package-name".parse().unwrap());
let mut v: Vec = vec![];
meta_package.serialize(&mut v).unwrap();
assert_eq!(std::str::from_utf8(v.as_slice()).unwrap(),
r#"{"name":"package-name","version":"0"}"#);
```
let meta_package = MetaPackage :: from_name ( " package - name " . parse () . unwrap () ) ; let mut v : Vec = vec! [] ; meta_package . serialize ( &mut v ) . unwrap () ; assert_eq! ( std :: str :: from_utf8 ( v . as_slice () ) . unwrap () r# " { " name " : " package - name " " version " : " 0 " } " # ) ; ` ` `