pub struct Word { /* private fields */ }Expand description
A single MIL-STD-1553B word
Format:
- 1 start bit (always 0 for valid Manchester encoding)
- 16 data bits
- 1 parity bit (odd parity over all 17 bits)
- 2 synchronization bits
Total: 20 bits
Implementations§
Source§impl Word
impl Word
Sourcepub fn new(data: u32, word_type: WordType) -> Result<Self>
pub fn new(data: u32, word_type: WordType) -> Result<Self>
Create a new word with validation
The 16 data bits should be in bits 16:1, parity in bit 17
Sourcepub fn new_unchecked(data: u32, word_type: WordType) -> Self
pub fn new_unchecked(data: u32, word_type: WordType) -> Self
Create a word without parity validation
Use with caution - only for constructing test data or when parity will be verified separately
Sourcepub fn get_data_bits(&self) -> u16
pub fn get_data_bits(&self) -> u16
Extract the 16 data bits (bits 16-1)
Sourcepub fn get_parity_bit(&self) -> bool
pub fn get_parity_bit(&self) -> bool
Extract the parity bit (bit 17)
Sourcepub fn get_sync_bits(&self) -> u8
pub fn get_sync_bits(&self) -> u8
Extract the sync bits (bits 19-18)
Sourcepub fn calculate_parity(data_bits: u16) -> u8
pub fn calculate_parity(data_bits: u16) -> u8
Calculate and set the correct parity bit for a word
Trait Implementations§
impl Copy for Word
impl Eq for Word
impl StructuralPartialEq for Word
Auto Trait Implementations§
impl Freeze for Word
impl RefUnwindSafe for Word
impl Send for Word
impl Sync for Word
impl Unpin for Word
impl UnwindSafe for Word
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