Skip to main content

Variant

Struct Variant 

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

A decoded variant that holds the type and the value of its child.

A variant carries a dynamic child type, so decode parses the child into a Value once and keeps it. Variant::value borrows that value. It walks no bytes again and clones nothing.

Variant is the one building block that allocates on decode. Variants occur only inside a{sv} metadata, so a dirtree walk or an xattr scan does not decode one.

A Variant also keeps the borrowed child bytes and signature. encode writes them again, so the output equals the input byte for byte. The encode builds no signature string.

Implementations§

Source§

impl<'a> Variant<'a>

Source

pub fn ty(&self) -> &Type

Returns the type of the child.

Source

pub fn value(&self) -> &Value

Returns the child as a Value that decode parsed once.

Trait Implementations§

Source§

impl<'a> GvDecode<'a> for Variant<'a>

Source§

fn decode(data: &'a [u8]) -> Result<Self>

Decodes a value from the slice that covers exactly its serialized form. Read more
Source§

impl<'a> GvEncode for Variant<'a>

Source§

fn encode(&self, out: &mut Vec<u8>) -> Result<()>

Appends the normal-form bytes of self to out. Read more
Source§

impl<'a> GvType for Variant<'a>

Source§

const SIGNATURE: &'static str = "v"

The GVariant type signature, or "" for a container type. Read more
Source§

const ALIGNMENT: usize = 8

The alignment of the serialized form, in bytes.
Source§

const FIXED_SIZE: Option<usize> = None

The serialized size, or None for a variable-size type.

Auto Trait Implementations§

§

impl<'a> Forget for Variant<'a>

§

impl<'a> Freeze for Variant<'a>

§

impl<'a> Move for Variant<'a>

§

impl<'a> RefUnwindSafe for Variant<'a>

§

impl<'a> Send for Variant<'a>
where BoxRaw<Type>: Send, NonZero<u64>: Send, RawVecInner: Send, &'a [u8]: Send, BoxRaw<Value>: Send, BoxRaw<(Type, Value)>: Send,

§

impl<'a> Sync for Variant<'a>
where BoxRaw<Type>: Sync, NonZero<u64>: Sync, RawVecInner: Sync, BoxRaw<Value>: Sync, BoxRaw<(Type, Value)>: Sync,

§

impl<'a> Unpin for Variant<'a>
where Box<Type>: Unpin, NonZero<u64>: Unpin, *const u8 is !null: Unpin, &'a [u8]: Unpin, Box<Value>: Unpin, Box<(Type, Value)>: Unpin,

§

impl<'a> UnsafeUnpin for Variant<'a>

§

impl<'a> UnwindSafe for Variant<'a>
where BoxRaw<Type>: UnwindSafe, NonZero<u64>: UnwindSafe, RawVecInner: UnwindSafe, &'a [u8]: UnwindSafe, BoxRaw<Value>: UnwindSafe, BoxRaw<(Type, Value)>: UnwindSafe,

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> 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, 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.