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§
Sourcetype Slice: RawEncoding + ?Sized
type Slice: RawEncoding + ?Sized
The trit slice encoding associated with this trit buffer encoding.
Required Methods§
Sourcefn with_capacity(cap: usize) -> Selfwhere
Self: Sized,
fn with_capacity(cap: usize) -> Selfwhere
Self: Sized,
Create a new empty buffer with a given capacity.
Sourcefn clear(&mut self)
fn clear(&mut self)
Clears the buffer, removing all values. Note that this method has no effect on the allocated capacity of the buffer.
Sourcefn push(&mut self, trit: <Self::Slice as RawEncoding>::Trit)
fn push(&mut self, trit: <Self::Slice as RawEncoding>::Trit)
Push a trit to the back of this buffer.
Sourcefn pop(&mut self) -> Option<<Self::Slice as RawEncoding>::Trit>
fn pop(&mut self) -> Option<<Self::Slice as RawEncoding>::Trit>
Pop a trit from the back of this buffer.
Sourcefn as_slice_mut(&mut self) -> &mut Self::Slice
fn as_slice_mut(&mut self) -> &mut Self::Slice
View the trits in this buffer as a mutable slice.
Provided Methods§
Sourcefn from_trits(trits: &[<Self::Slice as RawEncoding>::Trit]) -> Selfwhere
Self: Sized,
fn from_trits(trits: &[<Self::Slice as RawEncoding>::Trit]) -> Selfwhere
Self: Sized,
Create a new buffer containing the given trits.
Sourcefn into_encoding<T>(this: TritBuf<Self>) -> TritBuf<T>where
Self: Sized,
T: RawEncodingBuf,
T::Slice: RawEncoding<Trit = <Self::Slice as RawEncoding>::Trit>,
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