pub struct Datagram { /* private fields */ }
Expand description
Representation of a datagram
The total length is limited to 128 bits The bits of a telegram are internally enumerated from 0 to 127. A default datagram is expected to be empty (i.e. containing zero bits)
Implementations§
Source§impl Datagram
impl Datagram
pub fn len(&self) -> u8
pub fn is_empty(&self) -> bool
Sourcepub fn extract_data(&self, min: u8, max: u8) -> u128
pub fn extract_data(&self, min: u8, max: u8) -> u128
Extract a data slice from the datagram
§Args
min
- start index (included)max
- max index (not included)
§Returns
the extracted value
§Panics
if 0 <= min < max <= len() is violated
§Example
use manchester_code::Datagram;
let datagram = Datagram::new("0-111_10101_00001111");
assert_eq!(0b1111, datagram.extract_data(0, 4));
assert_eq!(0b1111, datagram.extract_data(0, 8));
assert_eq!(0b1111, datagram.extract_data(datagram.len()-5, datagram.len()));
Trait Implementations§
impl Copy for Datagram
impl Eq for Datagram
Auto Trait Implementations§
impl Freeze for Datagram
impl RefUnwindSafe for Datagram
impl Send for Datagram
impl Sync for Datagram
impl Unpin for Datagram
impl UnwindSafe for Datagram
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