pub struct PropertyView<'a> { /* private fields */ }Expand description
One property: the header is decoded, the value is untouched.
Implementations§
Source§impl<'a> PropertyView<'a>
impl<'a> PropertyView<'a>
Sourcepub fn raw(&self) -> &'a [u8] ⓘ
pub fn raw(&self) -> &'a [u8] ⓘ
The value’s raw bytes, the name_hash/kind header excluded.
Exactly what PropertyExt::size_no_header
measures for the owned value, and exactly what the writer emits for it.
Sourcepub fn shape(&self) -> Result<ValueShape, Error>
pub fn shape(&self) -> Result<ValueShape, Error>
The value’s wire shape, read from the few header bytes ahead of its body.
The same ValueShape the resolver’s type rule uses, filled by the rules of
ValueShape::of: a container’s or option’s item kind, a map’s key and value kinds, an
embed’s class. A pointer’s class is deliberately not recorded.
§Errors
Error::InvalidPropertyTypePrimitive if a header kind byte does not decode,
Error::InvalidNesting or Error::InvalidKeyType for a header the value model has
no value for, or Error::IOError if the value’s bytes end inside its header.
Sourcepub fn item_count(&self) -> Result<Option<u32>, Error>
pub fn item_count(&self) -> Result<Option<u32>, Error>
The element count of a container or a map, from the same header bytes.
None for every other kind, an option included: an option is not counted, and whether
it holds anything is OptionalView::is_some.
§Errors
Error::IOError if the value’s bytes end inside its header.
Source§impl PropertyView<'_>
impl PropertyView<'_>
Sourcepub fn value(&self) -> Result<PropertyValueEnum, Error>
pub fn value(&self) -> Result<PropertyValueEnum, Error>
Decodes the value — the whole subtree — into the owned representation.
§Errors
The same as the eager reader raises for the same bytes: Error::InvalidSize,
Error::InvalidNesting, Error::InvalidKeyType,
Error::MismatchedContainerTypes, Error::Utf8Error.