Struct VarZeroCow
struct VarZeroCow<'a, V: ?Sized> { ... }
Copy-on-write type that efficiently represents VarULE types as their bitstream representation.
The primary use case for VarULE types is the ability to store complex variable-length datastructures
inside variable-length collections like crate::VarZeroVec.
Underlying this ability is the fact that VarULE types can be efficiently represented as a flat
bytestream.
In zero-copy cases, sometimes one wishes to unconditionally use this bytestream representation, for example
to save stack size. A struct with five Cow<'a, str>s is not as stack-efficient as a single Cow containing
the bytestream representation of, say, Tuple5VarULE<str, str, str, str, str>.
This type helps in this case: It is logically a Cow<'a, V>, with some optimizations, that is guaranteed
to serialize as a byte stream in machine-readable scenarios.
During human-readable serialization, it will fall back to the serde impls on V, which ought to have
a human-readable variant.
Implementations
impl<'a, V: ?Sized> VarZeroCow<'a, V>
fn is_owned(self: &Self) -> boolWhether or not this is owned
fn as_bytes(self: &Self) -> &[u8]Get the byte representation of this type
Is also always a valid
Vand can be passed toV::from_bytes_unchecked()
impl<'a, V: VarULE + ?Sized> VarZeroCow<'a, V>
fn parse_bytes(bytes: &'a [u8]) -> Result<Self, UleError>Construct from a slice. Errors if the slice doesn't represent a valid
Vfn parse_owned_bytes(bytes: Box<[u8]>) -> Result<Self, UleError>Construct from an owned slice. Errors if the slice doesn't represent a valid
Vunsafe const fn from_bytes_unchecked(bytes: &'a [u8]) -> SelfConstruct from a slice that is known to represent a valid
VSafety
bytesmust be a validV, i.e. it must successfully pass throughV::parse_bytes()orV::validate_bytes().fn from_encodeable<E: EncodeAsVarULE<V>>(encodeable: &E) -> SelfConstruct this from an
EncodeAsVarULEversion of the contained typeWill always construct an owned version
fn new_borrowed(val: &'a V) -> SelfConstruct a new borrowed version of this
fn new_owned(val: Box<V>) -> SelfConstruct a new borrowed version of this
impl<'a, 'b, V: VarULE + ?Sized> ZeroFrom for VarZeroCow<'a, V>
fn zero_from(other: &'a VarZeroCow<'b, V>) -> Self
impl<'a, T: 'static + ?Sized> Yokeable for VarZeroCow<'static, T>
fn transform(self: &'a Self) -> &'a <Self as >::Outputfn transform_owned(self: Self) -> <Self as >::Outputunsafe fn make(from: <Self as >::Output) -> Selffn transform_mut<F>(self: &'a mut Self, f: F) where F: 'static + for<'b> FnOnce(&'b mut <Self as >::Output)
impl<'a, V> Freeze for VarZeroCow<'a, V>
impl<'a, V> RefUnwindSafe for VarZeroCow<'a, V>
impl<'a, V> Send for VarZeroCow<'a, V>
impl<'a, V> Sync for VarZeroCow<'a, V>
impl<'a, V> Unpin for VarZeroCow<'a, V>
impl<'a, V> UnsafeUnpin for VarZeroCow<'a, V>
impl<'a, V> UnwindSafe for VarZeroCow<'a, V>
impl<'a, V: ?Sized> Clone for VarZeroCow<'a, V>
fn clone(self: &Self) -> Self
impl<'a, V: VarULE + ?Sized + Eq> Eq for VarZeroCow<'a, V>
impl<'a, V: VarULE + ?Sized + Ord> Ord for VarZeroCow<'a, V>
fn cmp(self: &Self, other: &Self) -> Ordering
impl<'a, V: VarULE + ?Sized + PartialEq> PartialEq for VarZeroCow<'a, V>
fn eq(self: &Self, other: &Self) -> bool
impl<'a, V: VarULE + ?Sized + PartialOrd> PartialOrd for VarZeroCow<'a, V>
fn partial_cmp(self: &Self, other: &Self) -> Option<Ordering>
impl<'a, V: VarULE + ?Sized + fmt::Debug> Debug for VarZeroCow<'a, V>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result<(), Error>
impl<'a, V: VarULE + ?Sized> Deref for VarZeroCow<'a, V>
fn deref(self: &Self) -> &V
impl<'a, V: VarULE + ?Sized> EncodeAsVarULE for VarZeroCow<'a, V>
fn encode_var_ule_as_slices<R, impl FnOnce(&[&[u8]]) -> R: FnOnce(&[&[u8]]) -> R>(self: &Self, _: impl FnOnce(&[&[u8]]) -> R) -> Rfn encode_var_ule_len(self: &Self) -> usizefn encode_var_ule_write(self: &Self, dst: &mut [u8])
impl<'a, V: VarULE + ?Sized> From for VarZeroCow<'a, V>
fn from(other: Box<V>) -> Self
impl<'a, V: VarULE + ?Sized> From for VarZeroCow<'a, V>
fn from(other: &'a V) -> Self
impl<'a, V: VarULE + ?Sized> ZeroFrom for VarZeroCow<'a, V>
fn zero_from(other: &'a V) -> Self
impl<P, T> Receiver for VarZeroCow<'a, V>
impl<T> Any for VarZeroCow<'a, V>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for VarZeroCow<'a, V>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for VarZeroCow<'a, V>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for VarZeroCow<'a, V>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> ErasedDestructor for VarZeroCow<'a, V>
impl<T> From for VarZeroCow<'a, V>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for VarZeroCow<'a, V>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for VarZeroCow<'a, V>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for VarZeroCow<'a, V>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for VarZeroCow<'a, V>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>