RawEncodingBuf

Trait RawEncodingBuf 

Source
pub trait RawEncodingBuf {
    type Slice: RawEncoding + ?Sized;

    // Required methods
    fn new() -> Self
       where Self: Sized;
    fn with_capacity(cap: usize) -> Self
       where Self: Sized;
    fn clear(&mut self);
    fn push(&mut self, trit: <Self::Slice as RawEncoding>::Trit);
    fn pop(&mut self) -> Option<<Self::Slice as RawEncoding>::Trit>;
    fn as_slice(&self) -> &Self::Slice;
    fn as_slice_mut(&mut self) -> &mut Self::Slice;
    fn capacity(&self) -> usize;

    // Provided methods
    fn from_trits(trits: &[<Self::Slice as RawEncoding>::Trit]) -> Self
       where Self: Sized { ... }
    fn into_encoding<T>(this: TritBuf<Self>) -> TritBuf<T>
       where Self: Sized,
             T: RawEncodingBuf,
             T::Slice: RawEncoding<Trit = <Self::Slice as RawEncoding>::Trit> { ... }
}
Available on crate feature ternary_encoding only.
Expand description

A trait to be implemented by alternative trit encoding scheme buffers.

Required Associated Types§

Source

type Slice: RawEncoding + ?Sized

The trit slice encoding associated with this trit buffer encoding.

Required Methods§

Source

fn new() -> Self
where Self: Sized,

Create a new empty buffer.

Source

fn with_capacity(cap: usize) -> Self
where Self: Sized,

Create a new empty buffer with a given capacity.

Source

fn clear(&mut self)

Clears the buffer, removing all values. Note that this method has no effect on the allocated capacity of the buffer.

Source

fn push(&mut self, trit: <Self::Slice as RawEncoding>::Trit)

Push a trit to the back of this buffer.

Source

fn pop(&mut self) -> Option<<Self::Slice as RawEncoding>::Trit>

Pop a trit from the back of this buffer.

Source

fn as_slice(&self) -> &Self::Slice

View the trits in this buffer as a slice.

Source

fn as_slice_mut(&mut self) -> &mut Self::Slice

View the trits in this buffer as a mutable slice.

Source

fn capacity(&self) -> usize

Returns the number of trits the buffer can hold.

Provided Methods§

Source

fn from_trits(trits: &[<Self::Slice as RawEncoding>::Trit]) -> Self
where Self: Sized,

Create a new buffer containing the given trits.

Source

fn into_encoding<T>(this: TritBuf<Self>) -> TritBuf<T>
where Self: Sized, T: RawEncodingBuf, T::Slice: RawEncoding<Trit = <Self::Slice as RawEncoding>::Trit>,

Convert this encoding into another encoding. TODO: Rename this reencode

Implementors§