diff options
Diffstat (limited to 'rust/src/descriptor/mod.rs')
-rw-r--r-- | rust/src/descriptor/mod.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/rust/src/descriptor/mod.rs b/rust/src/descriptor/mod.rs index fdc4956..ba741dd 100644 --- a/rust/src/descriptor/mod.rs +++ b/rust/src/descriptor/mod.rs @@ -20,6 +20,7 @@ extern crate alloc; mod hash; +mod property; mod util; use crate::VbmetaData; @@ -30,13 +31,14 @@ use avb_bindgen::{ use core::{ffi::c_void, mem::size_of, slice}; pub use hash::{HashDescriptor, HashDescriptorFlags}; +pub use property::PropertyDescriptor; /// A single descriptor. // TODO(b/290110273): add support for full descriptor contents. #[derive(Debug)] pub enum Descriptor<'a> { /// Wraps `AvbPropertyDescriptor`. - Property(&'a [u8]), + Property(PropertyDescriptor<'a>), /// Wraps `AvbHashtreeDescriptor`. Hashtree(&'a [u8]), /// Wraps `AvbHashDescriptor`. @@ -60,6 +62,8 @@ pub enum DescriptorError { InvalidSize, /// A field that was supposed to be valid UTF-8 was not. InvalidUtf8, + /// Descriptor contents don't match what we expect. + InvalidContents, } /// `Result` type for `DescriptorError` errors. @@ -103,7 +107,9 @@ impl<'a> Descriptor<'a> { let contents = unsafe { slice::from_raw_parts(raw_descriptor as *const u8, total_size) }; match descriptor.tag.try_into() { - Ok(AvbDescriptorTag::AVB_DESCRIPTOR_TAG_PROPERTY) => Ok(Descriptor::Property(contents)), + Ok(AvbDescriptorTag::AVB_DESCRIPTOR_TAG_PROPERTY) => { + Ok(Descriptor::Property(PropertyDescriptor::new(contents)?)) + } Ok(AvbDescriptorTag::AVB_DESCRIPTOR_TAG_HASHTREE) => Ok(Descriptor::Hashtree(contents)), Ok(AvbDescriptorTag::AVB_DESCRIPTOR_TAG_HASH) => { Ok(Descriptor::Hash(HashDescriptor::new(contents)?)) |