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

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()));

Create a new datagram from “binary” string

Arguments
  • bit_repr - Bit representation as string of zeros and ones. Arbitrary delimiter signs (for readability) are ignored
Example
use manchester_code::Datagram;

let datagram = Datagram::new("0-111_10101_00001111");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Writes the defmt representation of self to fmt.

Access the n-th element via index

Panics
  • if the index is out of range
Example
use manchester_code::Datagram;

let datagram = Datagram::new("0-111_10101_00001111");
assert_eq!(1, datagram[0]);
assert_eq!(0, datagram[5]);

The returned type after indexing.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.