pub struct VaricodeEncoder { /* private fields */ }Expand description
Stateful Varicode bit-stream encoder.
Encodes ASCII bytes to a bit stream, inserting a 2-bit “00” gap between characters. The leading gap before the first character is suppressed.
Implementations§
Source§impl VaricodeEncoder
impl VaricodeEncoder
pub fn new() -> Self
Sourcepub fn push_preamble(&mut self, n_bits: usize)
pub fn push_preamble(&mut self, n_bits: usize)
Push n 0-bits (preamble — continuous phase reversals for AFC lock).
The preamble ends with zeros so the first character’s leading “00” gap is
naturally provided. We leave first = true so that push_byte after a
preamble does NOT insert an additional “00” before the codeword.
Sourcepub fn push_byte(&mut self, b: u8)
pub fn push_byte(&mut self, b: u8)
Push one ASCII byte. Inserts a “00” inter-character gap before the codeword (except the first).
Sourcepub fn push_postamble(&mut self, n_bits: usize)
pub fn push_postamble(&mut self, n_bits: usize)
Push n 1-bits (postamble — carrier hold / idle).
First inserts a “00” inter-character gap so the Varicode decoder can flush the last encoded character before the 1-bit idle sequence begins.
Sourcepub fn next_bit(&mut self) -> Option<u8>
pub fn next_bit(&mut self) -> Option<u8>
Pop the next bit. Returns None when the queue is empty.
pub fn is_empty(&self) -> bool
Sourcepub fn drain_bits(&mut self) -> Vec<u8> ⓘ
pub fn drain_bits(&mut self) -> Vec<u8> ⓘ
Drain all pending bits into a Vec<u8>.
Trait Implementations§
Source§impl Clone for VaricodeEncoder
impl Clone for VaricodeEncoder
Source§fn clone(&self) -> VaricodeEncoder
fn clone(&self) -> VaricodeEncoder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more