pub struct Pattern<const N: usize> { /* private fields */ }Expand description
Represents a pattern with a fixed number of chunks.
§Parameters
N- Number of pattern chunks in range [2, 6]
Implementations§
Source§impl<const N: usize> Pattern<N>
impl<const N: usize> Pattern<N>
Sourcepub const fn from(chunks: [u8; N]) -> Self
pub const fn from(chunks: [u8; N]) -> Self
Construct a new Pattern from a fixed-size array.
§Panics
- If the length of
chunksis not in the range [2, 6]. - If elements of
chunksis not distinct.
Sourcepub const unsafe fn from_unchecked(chunks: [u8; N]) -> Self
pub const unsafe fn from_unchecked(chunks: [u8; N]) -> Self
Construct a new Pattern from a fixed-size array, without checking.
§Safety
- The length of
chunksmust be in the range [2, 6] - Elements of
chunksmust be distinct.
Sourcepub fn from_bytes(chunks: impl AsRef<[u8]>) -> Option<Self>
pub fn from_bytes(chunks: impl AsRef<[u8]>) -> Option<Self>
Construct a new Pattern from a slice of bytes.
pub const fn chunks_len(&self) -> usize
pub const fn measure_encode_capacity(&self, bits: u8) -> usize
Sourcepub fn encode(&self, bits: u8) -> PatternWord
pub fn encode(&self, bits: u8) -> PatternWord
Encodes a 6-bit value into a character pattern.
The encoding distributes the bits across N chunks, where each chunk
determines the repeat count for its corresponding character.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize> Freeze for Pattern<N>
impl<const N: usize> RefUnwindSafe for Pattern<N>
impl<const N: usize> Send for Pattern<N>
impl<const N: usize> Sync for Pattern<N>
impl<const N: usize> Unpin for Pattern<N>
impl<const N: usize> UnwindSafe for Pattern<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more