Struct fuchsia_pkg::MetaPackage
source · 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
source§fn eq(&self, other: &MetaPackage) -> bool
fn eq(&self, other: &MetaPackage) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)