#[repr(transparent)]
pub struct ZeroSlice<T: AsULE>([T::ULE]);
Expand description

A zero-copy “slice”, i.e. the zero-copy version of [T]. This behaves similarly to ZeroVec<T>, however ZeroVec<T> is allowed to contain owned data and as such is ideal for deserialization since most human readable serialization formats cannot unconditionally deserialize zero-copy.

This type can be used inside VarZeroVec<T> and ZeroMap: This essentially allows for the construction of zero-copy types isomorphic to Vec<Vec<T>> by instead using VarZeroVec<ZeroSlice<T>>. See the VarZeroVec docs for an example.

Examples

Const-construct a ZeroSlice of u16:

use zerovec::ule::AsULE;
use zerovec::ZeroSlice;

const DATA: &ZeroSlice<u16> =
    ZeroSlice::<u16>::from_ule_slice(&<u16 as AsULE>::ULE::from_array([
        211, 281, 421, 32973,
    ]));

assert_eq!(DATA.get(1), Some(281));

Tuple Fields§

§0: [T::ULE]

Implementations§

source§

impl<T> ZeroSlice<T>where T: AsULE,

source

pub const fn new_empty() -> &'static Self

Returns an empty slice.

source

pub const fn as_zerovec(&self) -> ZeroVec<'_, T>

Get this ZeroSlice as a borrowed ZeroVec

ZeroSlice does not have most of the methods that ZeroVec does, so it is recommended to convert it to a ZeroVec before doing anything.

source

pub fn parse_byte_slice(bytes: &[u8]) -> Result<&Self, ZeroVecError>

Attempt to construct a &ZeroSlice<T> from a byte slice, returning an error if it’s not a valid byte sequence

source

pub const unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self

Uses a &[u8] buffer as a ZeroVec<T> without any verification.

Safety

bytes need to be an output from ZeroSlice::as_bytes().

source

pub const fn from_ule_slice(slice: &[T::ULE]) -> &Self

Construct a &ZeroSlice<T> from a slice of ULEs.

This function can be used for constructing ZeroVecs in a const context, avoiding parsing checks.

See ZeroSlice for an example.

source

pub fn from_boxed_slice(slice: Box<[T::ULE]>) -> Box<Self>

Construct a Box<ZeroSlice<T>> from a boxed slice of ULEs

source

pub fn as_bytes(&self) -> &[u8]

Returns this slice as its underlying &[u8] byte buffer representation.

Useful for serialization.

Example
use zerovec::ZeroVec;

// The little-endian bytes correspond to the numbers on the following line.
let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let nums: &[u16] = &[211, 281, 421, 32973];

let zerovec = ZeroVec::alloc_from_slice(nums);

assert_eq!(bytes, zerovec.as_bytes());
source

pub const fn as_ule_slice(&self) -> &[T::ULE]

Dereferences this slice as &[T::ULE].

source

pub const fn len(&self) -> usize

Returns the number of elements in this slice.

Example
use zerovec::ule::AsULE;
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");

assert_eq!(4, zerovec.len());
assert_eq!(
    bytes.len(),
    zerovec.len() * std::mem::size_of::<<u16 as AsULE>::ULE>()
);
source

pub const fn is_empty(&self) -> bool

Returns whether this slice is empty.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");
assert!(!zerovec.is_empty());

let emptyvec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(&[]).expect("infallible");
assert!(emptyvec.is_empty());
source§

impl<T> ZeroSlice<T>where T: AsULE,

source

pub fn get(&self, index: usize) -> Option<T>

Gets the element at the specified index. Returns None if out of range.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");

assert_eq!(zerovec.get(2), Some(421));
assert_eq!(zerovec.get(4), None);
source

pub fn get_as_array<const N: usize>(&self) -> Option<[T; N]>

Gets the entire slice as an array of length N. Returns None if the slice does not have exactly N elements.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");
let array: [u16; 4] =
    zerovec.get_as_array().expect("should be 4 items in array");

assert_eq!(array[2], 421);
source

pub fn get_subslice(&self, range: Range<usize>) -> Option<&ZeroSlice<T>>

Gets a subslice of elements within a certain range. Returns None if the range is out of bounds of this ZeroSlice.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");

assert_eq!(
    zerovec.get_subslice(1..3),
    Some(&*ZeroVec::from_slice_or_alloc(&[0x0119, 0x01A5]))
);
assert_eq!(zerovec.get_subslice(3..5), None);
source

pub fn get_ule_ref(&self, index: usize) -> Option<&T::ULE>

Get a borrowed reference to the underlying ULE type at a specified index.

Prefer Self::get() over this method where possible since working directly with ULE types is less ergonomic

source

pub const fn cast<P>(&self) -> &ZeroSlice<P>where P: AsULE<ULE = T::ULE>,

Casts a ZeroSlice<T> to a compatible ZeroSlice<P>.

T and P are compatible if they have the same ULE representation.

If the ULEs of T and P are different, use Self::try_as_converted().

Examples
use zerovec::ZeroSlice;

const BYTES: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
const ZS_U16: &ZeroSlice<u16> = {
    match ZeroSlice::<u16>::try_from_bytes(BYTES) {
        Ok(s) => s,
        Err(_) => unreachable!(),
    }
};

let zs_i16: &ZeroSlice<i16> = ZS_U16.cast();

assert_eq!(ZS_U16.get(3), Some(32973));
assert_eq!(zs_i16.get(3), Some(-32563));
source

pub fn try_as_converted<P: AsULE>(&self) -> Result<&ZeroSlice<P>, ZeroVecError>

Converts a &ZeroSlice<T> into a &ZeroSlice<P>.

The resulting slice will have the same length as the original slice if and only if T::ULE and P::ULE are the same size.

If T and P have the exact same ULE, use Self::cast().

Examples
use zerovec::ZeroSlice;

const BYTES: &[u8] = &[0x7F, 0xF3, 0x01, 0x00, 0x49, 0xF6, 0x01, 0x00];
const ZS_U32: &ZeroSlice<u32> = {
    match ZeroSlice::<u32>::try_from_bytes(BYTES) {
        Ok(s) => s,
        Err(_) => unreachable!(),
    }
};

let zs_u8_4: &ZeroSlice<[u8; 4]> =
    ZS_U32.try_as_converted().expect("valid code points");

assert_eq!(ZS_U32.get(0), Some(127871));
assert_eq!(zs_u8_4.get(0), Some([0x7F, 0xF3, 0x01, 0x00]));
source

pub fn first(&self) -> Option<T>

Gets the first element. Returns None if empty.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");

assert_eq!(zerovec.first(), Some(211));
source

pub fn last(&self) -> Option<T>

Gets the last element. Returns None if empty.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");

assert_eq!(zerovec.last(), Some(32973));
source

pub fn iter( &self ) -> impl DoubleEndedIterator<Item = T> + ExactSizeIterator<Item = T> + '_

Gets an iterator over the elements.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");
let mut it = zerovec.iter();

assert_eq!(it.next(), Some(211));
assert_eq!(it.next(), Some(281));
assert_eq!(it.next(), Some(421));
assert_eq!(it.next(), Some(32973));
assert_eq!(it.next(), None);
source

pub fn split_first(&self) -> Option<(T, &ZeroSlice<T>)>

Returns a tuple with the first element and a subslice of the remaining elements.

Example
use zerovec::ule::AsULE;
use zerovec::ZeroSlice;

const DATA: &ZeroSlice<u16> =
    ZeroSlice::<u16>::from_ule_slice(&<u16 as AsULE>::ULE::from_array([
        211, 281, 421, 32973,
    ]));
const EXPECTED_VALUE: (u16, &ZeroSlice<u16>) = (
    211,
    ZeroSlice::<u16>::from_ule_slice(&<u16 as AsULE>::ULE::from_array([
        281, 421, 32973,
    ])),
);
assert_eq!(EXPECTED_VALUE, DATA.split_first().unwrap());
source§

impl<T> ZeroSlice<T>where T: AsULE + Ord,

Binary searches a sorted ZeroVec<T> for the given element. For more information, see the primitive function binary_search.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");

assert_eq!(zerovec.binary_search(&281), Ok(1));
assert_eq!(zerovec.binary_search(&282), Err(2));
source§

impl<T> ZeroSlice<T>where T: AsULE,

source

pub fn binary_search_by( &self, predicate: impl FnMut(T) -> Ordering ) -> Result<usize, usize>

Binary searches a sorted ZeroVec<T> based on a given predicate. For more information, see the primitive function binary_search_by.

Example
use zerovec::ZeroVec;

let bytes: &[u8] = &[0xD3, 0x00, 0x19, 0x01, 0xA5, 0x01, 0xCD, 0x80];
let zerovec: ZeroVec<u16> =
    ZeroVec::parse_byte_slice(bytes).expect("infallible");

assert_eq!(zerovec.binary_search_by(|x| x.cmp(&281)), Ok(1));
assert_eq!(zerovec.binary_search_by(|x| x.cmp(&282)), Err(2));
source§

impl ZeroSlice<u8>

source

pub const fn try_from_bytes(bytes: &[u8]) -> Result<&Self, ZeroVecError>

This function can be used for constructing ZeroVecs in a const context, avoiding parsing checks.

This cannot be generic over T because of current limitations in const, but if this method is needed in a non-const context, check out ZeroSlice::parse_byte_slice() instead.

See ZeroSlice::cast() for an example.

source§

impl ZeroSlice<u16>

source

pub const fn try_from_bytes(bytes: &[u8]) -> Result<&Self, ZeroVecError>

This function can be used for constructing ZeroVecs in a const context, avoiding parsing checks.

This cannot be generic over T because of current limitations in const, but if this method is needed in a non-const context, check out ZeroSlice::parse_byte_slice() instead.

See ZeroSlice::cast() for an example.

source§

impl ZeroSlice<u32>

source

pub const fn try_from_bytes(bytes: &[u8]) -> Result<&Self, ZeroVecError>

This function can be used for constructing ZeroVecs in a const context, avoiding parsing checks.

This cannot be generic over T because of current limitations in const, but if this method is needed in a non-const context, check out ZeroSlice::parse_byte_slice() instead.

See ZeroSlice::cast() for an example.

source§

impl ZeroSlice<u64>

source

pub const fn try_from_bytes(bytes: &[u8]) -> Result<&Self, ZeroVecError>

This function can be used for constructing ZeroVecs in a const context, avoiding parsing checks.

This cannot be generic over T because of current limitations in const, but if this method is needed in a non-const context, check out ZeroSlice::parse_byte_slice() instead.

See ZeroSlice::cast() for an example.

source§

impl ZeroSlice<u128>

source

pub const fn try_from_bytes(bytes: &[u8]) -> Result<&Self, ZeroVecError>

This function can be used for constructing ZeroVecs in a const context, avoiding parsing checks.

This cannot be generic over T because of current limitations in const, but if this method is needed in a non-const context, check out ZeroSlice::parse_byte_slice() instead.

See ZeroSlice::cast() for an example.

source§

impl ZeroSlice<bool>

source

pub const fn try_from_bytes(bytes: &[u8]) -> Result<&Self, ZeroVecError>

This function can be used for constructing ZeroVecs in a const context, avoiding parsing checks.

This cannot be generic over T because of current limitations in const, but if this method is needed in a non-const context, check out ZeroSlice::parse_byte_slice() instead.

See ZeroSlice::cast() for an example.

Trait Implementations§

source§

impl<T: AsULE> AsRef<ZeroSlice<T>> for &[T::ULE]

source§

fn as_ref(&self) -> &ZeroSlice<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: AsULE> AsRef<ZeroSlice<T>> for Vec<T::ULE>

source§

fn as_ref(&self) -> &ZeroSlice<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'a, T: AsULE> AsRef<ZeroSlice<T>> for ZeroVec<'a, T>

source§

fn as_ref(&self) -> &ZeroSlice<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Debug for ZeroSlice<T>where T: AsULE + Debug,

source§

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

Formats the value using the given formatter. Read more
source§

impl<T> Default for &ZeroSlice<T>where T: AsULE,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T> EncodeAsVarULE<ZeroSlice<T>> for &[T]where T: AsULE + 'static,

source§

fn encode_var_ule_as_slices<R>(&self, _: impl FnOnce(&[&[u8]]) -> R) -> R

Calls cb with a piecewise list of byte slices that when concatenated produce the memory pattern of the corresponding instance of T. Read more
source§

fn encode_var_ule_len(&self) -> usize

Return the length, in bytes, of the corresponding VarULE type
source§

fn encode_var_ule_write(&self, dst: &mut [u8])

Write the corresponding VarULE type to the dst buffer. dst should be the size of Self::encode_var_ule_len()
source§

impl<T> EncodeAsVarULE<ZeroSlice<T>> for Vec<T>where T: AsULE + 'static,

source§

fn encode_var_ule_as_slices<R>(&self, _: impl FnOnce(&[&[u8]]) -> R) -> R

Calls cb with a piecewise list of byte slices that when concatenated produce the memory pattern of the corresponding instance of T. Read more
source§

fn encode_var_ule_len(&self) -> usize

Return the length, in bytes, of the corresponding VarULE type
source§

fn encode_var_ule_write(&self, dst: &mut [u8])

Write the corresponding VarULE type to the dst buffer. dst should be the size of Self::encode_var_ule_len()
source§

impl<T> EncodeAsVarULE<ZeroSlice<T>> for ZeroVec<'_, T>where T: AsULE + 'static,

source§

fn encode_var_ule_as_slices<R>(&self, _: impl FnOnce(&[&[u8]]) -> R) -> R

Calls cb with a piecewise list of byte slices that when concatenated produce the memory pattern of the corresponding instance of T. Read more
source§

fn encode_var_ule_len(&self) -> usize

Return the length, in bytes, of the corresponding VarULE type
source§

fn encode_var_ule_write(&self, dst: &mut [u8])

Write the corresponding VarULE type to the dst buffer. dst should be the size of Self::encode_var_ule_len()
source§

impl<T: AsULE + Ord> Ord for ZeroSlice<T>

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
source§

impl<T> PartialEq<[T]> for ZeroSlice<T>where T: AsULE + PartialEq,

source§

fn eq(&self, other: &[T]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PartialEq<ZeroSlice<T>> for ZeroSlice<T>where T: AsULE + PartialEq,

source§

fn eq(&self, other: &ZeroSlice<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq<ZeroSlice<T>> for ZeroVec<'a, T>where T: AsULE + PartialEq,

source§

fn eq(&self, other: &ZeroSlice<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq<ZeroVec<'a, T>> for ZeroSlice<T>where T: AsULE + PartialEq,

source§

fn eq(&self, other: &ZeroVec<'a, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: AsULE + PartialOrd> PartialOrd<ZeroSlice<T>> for ZeroSlice<T>

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: AsULE + 'static> VarULE for ZeroSlice<T>

source§

fn validate_byte_slice(bytes: &[u8]) -> Result<(), ZeroVecError>

Validates a byte slice, &[u8]. Read more
source§

unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self

Takes a byte slice, &[u8], and return it as &Self with the same lifetime, assuming that this byte slice has previously been run through Self::parse_byte_slice() with success. Read more
source§

fn parse_byte_slice(bytes: &[u8]) -> Result<&Self, ZeroVecError>

Parses a byte slice, &[u8], and return it as &Self with the same lifetime. Read more
source§

fn as_byte_slice(&self) -> &[u8]

Given &Self, returns a &[u8] with the same lifetime. Read more
source§

fn to_boxed(&self) -> Box<Self>

Allocate on the heap as a Box<T>
source§

impl<'zf, T> ZeroFrom<'zf, ZeroSlice<T>> for &'zf ZeroSlice<T>where T: 'static + AsULE + ?Sized,

source§

fn zero_from(other: &'zf ZeroSlice<T>) -> Self

Clone the other C into a struct that may retain references into C.
source§

impl<'zf, T> ZeroFrom<'zf, ZeroSlice<T>> for ZeroVec<'zf, T>where T: 'static + AsULE + ?Sized,

source§

fn zero_from(other: &'zf ZeroSlice<T>) -> Self

Clone the other C into a struct that may retain references into C.
source§

impl<'a, T> ZeroMapKV<'a> for ZeroSlice<T>where T: AsULE + 'static,

§

type Container = VarZeroVec<'a, ZeroSlice<T>, Index16>

The container that can be used with this type: ZeroVec or VarZeroVec.
§

type Slice = VarZeroSlice<ZeroSlice<T>, Index16>

§

type GetType = ZeroSlice<T>

The type produced by Container::get() Read more
§

type OwnedType = Box<ZeroSlice<T>, Global>

The type produced by Container::replace() and Container::remove(), also used during deserialization. If Self is human readable serialized, deserializing to Self::OwnedType should produce the same value once passed through Self::owned_as_self() Read more
source§

impl<T> ZeroVecLike<T> for ZeroSlice<T>where T: AsULE + Copy,

§

type GetType = <T as AsULE>::ULE

The type returned by Self::get()
§

type SliceVariant = ZeroSlice<T>

A fully borrowed version of this
source§

fn zvl_new_borrowed() -> &'static Self::SliceVariant

Create a new, empty borrowed variant
Search for a key in a sorted vector, returns Ok(index) if found, returns Err(insert_index) if not found, where insert_index is the index where it should be inserted to maintain sort order.
source§

fn zvl_binary_search_in_range( &self, k: &T, range: Range<usize> ) -> Option<Result<usize, usize>>where T: Ord,

Search for a key within a certain range in a sorted vector. Returns None if the range is out of bounds, and Ok or Err in the same way as zvl_binary_search. Indices are returned relative to the start of the range.
source§

fn zvl_binary_search_by( &self, predicate: impl FnMut(&T) -> Ordering ) -> Result<usize, usize>

Search for a key in a sorted vector by a predicate, returns Ok(index) if found, returns Err(insert_index) if not found, where insert_index is the index where it should be inserted to maintain sort order.
source§

fn zvl_binary_search_in_range_by( &self, predicate: impl FnMut(&T) -> Ordering, range: Range<usize> ) -> Option<Result<usize, usize>>

Search for a key within a certain range in a sorted vector by a predicate. Returns None if the range is out of bounds, and Ok or Err in the same way as zvl_binary_search. Indices are returned relative to the start of the range.
source§

fn zvl_get(&self, index: usize) -> Option<&T::ULE>

Get element at index
source§

fn zvl_len(&self) -> usize

The length of this vector
source§

fn zvl_as_borrowed(&self) -> &ZeroSlice<T>

Construct a borrowed variant by borrowing from &self. Read more
source§

fn zvl_get_as_t<R>(g: &Self::GetType, f: impl FnOnce(&T) -> R) -> R

Obtain a reference to T, passed to a closure Read more
source§

fn zvl_is_empty(&self) -> bool

Check if this vector is empty
source§

impl<T> Eq for ZeroSlice<T>where T: AsULE + Eq,

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for ZeroSlice<T>where <T as AsULE>::ULE: RefUnwindSafe,

§

impl<T> Send for ZeroSlice<T>where <T as AsULE>::ULE: Send,

§

impl<T> !Sized for ZeroSlice<T>

§

impl<T> Sync for ZeroSlice<T>where <T as AsULE>::ULE: Sync,

§

impl<T> Unpin for ZeroSlice<T>where <T as AsULE>::ULE: Unpin,

§

impl<T> UnwindSafe for ZeroSlice<T>where <T as AsULE>::ULE: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> EncodeAsVarULE<T> for Twhere T: VarULE + ?Sized,

source§

fn encode_var_ule_as_slices<R>(&self, cb: impl FnOnce(&[&[u8]]) -> R) -> R

Calls cb with a piecewise list of byte slices that when concatenated produce the memory pattern of the corresponding instance of T. Read more
source§

fn encode_var_ule_len(&self) -> usize

Return the length, in bytes, of the corresponding VarULE type
source§

fn encode_var_ule_write(&self, dst: &mut [u8])

Write the corresponding VarULE type to the dst buffer. dst should be the size of Self::encode_var_ule_len()
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<T> ErasedDestructor for Twhere T: 'static,