Skip to main content

Stash

Enum Stash 

Source
pub enum Stash<C, B> {
    Typed(C),
    Bytes(B),
    Align(Box<[u64]>),
}
Expand description

A container of either typed columns, or serialized bytes that can be borrowed as the former.

When B dereferences to a byte slice, the container can be borrowed as if the container type C. This container inherents the readable properties of C through borrowing, but does not implement the traits itself.

The container can be cleared and pushed into. When cleared it reverts to a typed variant, and when pushed into if the typed variant it will accept the item, and if not it will panic.

Variants§

§

Typed(C)

The typed variant of the container.

§

Bytes(B)

The bytes variant of the container.

§

Align(Box<[u64]>)

Relocated, aligned binary data, if Bytes doesn’t work for some reason.

Most commonly this works around misaligned binary data, but it can also be useful if the B type is a scarce resource that should be released.

Implementations§

Source§

impl<C: ContainerBytes, B: Deref<Target = [u8]>> Stash<C, B>

Source

pub fn borrow<'a>(&'a self) -> <C as Borrow>::Borrowed<'a>

Borrows the contents, either from a typed container or by decoding serialized bytes.

This method is relatively cheap but is not free.

Source

pub fn length_in_bytes(&self) -> usize

The number of bytes needed to write the contents using the Indexed encoder.

Source

pub fn into_bytes<W: Write>(&self, writer: &mut W)

Write the contents into a std::io::Write using the Indexed encoder.

Trait Implementations§

Source§

impl<C: ContainerBytes, B: Deref<Target = [u8]> + Clone + 'static> Borrow for Stash<C, B>

Source§

type Ref<'a> = <C as Borrow>::Ref<'a>

For each lifetime, a reference with that lifetime. Read more
Source§

type Borrowed<'a> = <C as Borrow>::Borrowed<'a>

The type of a borrowed container. Read more
Source§

fn borrow<'a>(&'a self) -> Self::Borrowed<'a>

Converts a reference to the type to a borrowed variant.
Source§

fn reborrow<'b, 'a: 'b>(item: Self::Borrowed<'a>) -> Self::Borrowed<'b>
where Self: 'a,

Reborrows the borrowed type to a shorter lifetime. See Columnar::reborrow for details.
Source§

fn reborrow_ref<'b, 'a: 'b>(item: Self::Ref<'a>) -> Self::Ref<'b>
where Self: 'a,

Reborrows the borrowed type to a shorter lifetime. See Columnar::reborrow for details.
Source§

impl<C: Clear + Default, B> Clear for Stash<C, B>

Source§

fn clear(&mut self)

Clears self, without changing its capacity.
Source§

impl<C: Clone, B: Clone> Clone for Stash<C, B>

Source§

fn clone(&self) -> Stash<C, B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<C: Default, B> Default for Stash<C, B>

Source§

fn default() -> Self

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

impl<C: Container, B: Deref<Target = [u8]>> From<B> for Stash<C, B>

Source§

fn from(bytes: B) -> Self

Converts to this type from the input type.
Source§

impl<C: ContainerBytes, B: Deref<Target = [u8]>> Len for Stash<C, B>

Source§

fn len(&self) -> usize

The number of contained elements.
Source§

fn is_empty(&self) -> bool

Whether this contains no elements.
Source§

impl<T, C: Container + Push<T>, B> Push<T> for Stash<C, B>

Source§

fn push(&mut self, item: T)

Pushes an item onto self.
Source§

fn extend(&mut self, iter: impl IntoIterator<Item = T>)

Pushes elements of an iterator onto self.

Auto Trait Implementations§

§

impl<C, B> Freeze for Stash<C, B>
where C: Freeze, B: Freeze,

§

impl<C, B> RefUnwindSafe for Stash<C, B>

§

impl<C, B> Send for Stash<C, B>
where C: Send, B: Send,

§

impl<C, B> Sync for Stash<C, B>
where C: Sync, B: Sync,

§

impl<C, B> Unpin for Stash<C, B>
where C: Unpin, B: Unpin,

§

impl<C, B> UnwindSafe for Stash<C, B>
where C: UnwindSafe, B: 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> 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 = 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 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.