pub struct MetaPackage { /* private fields */ }
Expand description
A MetaPackage
represents the “meta/package” file of a meta.far (which is
a Fuchsia archive file of a Fuchsia package).
It validates that the name and variant (called “version” in json) are valid.
Implementations§
Source§impl MetaPackage
impl MetaPackage
pub const PATH: &'static str = "meta/package"
Sourcepub fn from_name_and_variant_zero(name: PackageName) -> Self
pub fn from_name_and_variant_zero(name: PackageName) -> Self
Create a MetaPackage
with name
and variant 0.
Sourcepub fn name(&self) -> &PackageName
pub fn name(&self) -> &PackageName
Returns the package’s name.
Sourcepub fn variant(&self) -> &PackageVariant
pub fn variant(&self) -> &PackageVariant
Returns the package’s variant.
Sourcepub fn into_path(self) -> PackagePath
pub fn into_path(self) -> PackagePath
Convert into PackagePath.
Sourcepub fn deserialize(reader: impl BufRead) -> Result<Self, MetaPackageError>
pub fn deserialize(reader: impl BufRead) -> Result<Self, MetaPackageError>
Deserializes a MetaPackage
from json.
§Examples
let json = r#"
{"name": "package-name",
"version": "0"}"#;
assert_eq!(
MetaPackage::deserialize(json.as_bytes()).unwrap(),
MetaPackage::from_name(
"package-name".parse().unwrap(),
"0".parse().unwrap(),
)
);
Sourcepub fn serialize(&self, writer: impl Write) -> Result<(), MetaPackageError>
pub fn serialize(&self, writer: impl Write) -> Result<(), MetaPackageError>
Serializes a MetaPackage
to json.
§Examples
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"}"#);
Trait Implementations§
Source§impl Clone for MetaPackage
impl Clone for MetaPackage
Source§fn clone(&self) -> MetaPackage
fn clone(&self) -> MetaPackage
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for MetaPackage
impl Debug for MetaPackage
Source§impl PartialEq for MetaPackage
impl PartialEq for MetaPackage
impl Eq for MetaPackage
impl StructuralPartialEq for MetaPackage
Auto Trait Implementations§
impl Freeze for MetaPackage
impl RefUnwindSafe for MetaPackage
impl Send for MetaPackage
impl Sync for MetaPackage
impl Unpin for MetaPackage
impl UnwindSafe for MetaPackage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)