Skip to main content

PropertyView

Struct PropertyView 

Source
pub struct PropertyView<'a> { /* private fields */ }
Expand description

One property: the header is decoded, the value is untouched.

Implementations§

Source§

impl<'a> PropertyView<'a>

Source

pub fn name_hash(&self) -> BinHash

The property’s name hash.

Source

pub fn kind(&self) -> Kind

The kind of the property’s value.

Source

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.

Source

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.

Source

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

pub fn value_view(&self) -> Result<ValueView<'a>, Error>

Descends into the value without materializing it.

§Errors

See ValueView.

Source§

impl PropertyView<'_>

Source

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.

Trait Implementations§

Source§

impl Clone for PropertyView<'_>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PropertyView<'_>

Source§

impl Debug for PropertyView<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PropertyView<'a>

§

impl<'a> RefUnwindSafe for PropertyView<'a>

§

impl<'a> Send for PropertyView<'a>

§

impl<'a> Sync for PropertyView<'a>

§

impl<'a> Unpin for PropertyView<'a>

§

impl<'a> UnsafeUnpin for PropertyView<'a>

§

impl<'a> UnwindSafe for PropertyView<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.