pub trait RawEncoding {
type Trit: Trit;
type Buf: RawEncodingBuf<Slice = Self>;
const TRITS_PER_BYTE: usize;
// Required methods
fn empty() -> &'static Self;
fn len(&self) -> usize;
fn as_i8_slice(&self) -> &[i8];
unsafe fn as_i8_slice_mut(&mut self) -> &mut [i8];
unsafe fn get_unchecked(&self, index: usize) -> Self::Trit;
unsafe fn set_unchecked(&mut self, index: usize, trit: Self::Trit);
unsafe fn slice_unchecked(&self, range: Range<usize>) -> &Self;
unsafe fn slice_unchecked_mut(&mut self, range: Range<usize>) -> &mut Self;
fn is_valid(repr: i8) -> bool;
unsafe fn from_raw_unchecked(b: &[i8], num_trits: usize) -> &Self;
unsafe fn from_raw_unchecked_mut(
b: &mut [i8],
num_trits: usize,
) -> &mut Self;
}Available on crate feature
ternary_encoding only.Expand description
A trait to be implemented by alternative trit encoding scheme slices.
Required Associated Constants§
Sourceconst TRITS_PER_BYTE: usize
const TRITS_PER_BYTE: usize
The number of trits that fit into this trit slice encoding.
Required Associated Types§
Sourcetype Buf: RawEncodingBuf<Slice = Self>
type Buf: RawEncodingBuf<Slice = Self>
The trit buffer encoding associated with this trit slice encoding.
Required Methods§
Sourcefn as_i8_slice(&self) -> &[i8]
fn as_i8_slice(&self) -> &[i8]
Interpret the raw data of this encoding as a slice of i8.
Sourceunsafe fn as_i8_slice_mut(&mut self) -> &mut [i8]
unsafe fn as_i8_slice_mut(&mut self) -> &mut [i8]
Interpret the raw data of this encoding as a mutable slice of i8.
Sourceunsafe fn get_unchecked(&self, index: usize) -> Self::Trit
unsafe fn get_unchecked(&self, index: usize) -> Self::Trit
Get the trit at the given index
Sourceunsafe fn set_unchecked(&mut self, index: usize, trit: Self::Trit)
unsafe fn set_unchecked(&mut self, index: usize, trit: Self::Trit)
Set the trit at the given index
Sourceunsafe fn slice_unchecked(&self, range: Range<usize>) -> &Self
unsafe fn slice_unchecked(&self, range: Range<usize>) -> &Self
Get a slice of this slice
Sourceunsafe fn slice_unchecked_mut(&mut self, range: Range<usize>) -> &mut Self
unsafe fn slice_unchecked_mut(&mut self, range: Range<usize>) -> &mut Self
Get a mutable slice of this slice
Sourcefn is_valid(repr: i8) -> bool
fn is_valid(repr: i8) -> bool
Decide whether a byte is a valid series of trits in this encoding
Sourceunsafe fn from_raw_unchecked(b: &[i8], num_trits: usize) -> &Self
unsafe fn from_raw_unchecked(b: &[i8], num_trits: usize) -> &Self
Unsafely reinterpret a slice of bytes as trit slice
Sourceunsafe fn from_raw_unchecked_mut(b: &mut [i8], num_trits: usize) -> &mut Self
unsafe fn from_raw_unchecked_mut(b: &mut [i8], num_trits: usize) -> &mut Self
Unsafely reinterpret a slice of bytes as trit slice
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.