[][src]Struct arinc_429::Message

pub struct Message(_);

An ARINC 429 message

The bits of a message are represented exactly as transmitted on the wires, with the least significant bit transmitted first.

The label field is in the 8 least significant bits. Because the most significant digit of the label is transmitted first, the label field is in the reverse of the usual bit order.

The parity bit is the most significant bit.

Conversions

The u32::from(Message) and Message::from(u32) From implementations copy bits with no changes.

Some ARINC 429 adapters use a different representation, where the bits of the label field are reversed from their on-wire representation. The methods Message::from_bits_label_swapped() and Message::bits_label_swapped() implement this conversion.

Conversions never panic.

Examples

Create a message

let message = Message::from(0x10000056);
assert_eq!(0x10000056, u32::from(message));

Label bit swapping

let message = Message::from_bits_label_swapped(0x10000056);
assert_eq!(0x1000006a, u32::from(message));

Methods

impl Message[src]

pub fn bits(&self) -> u32[src]

Returns the bits that represent this message

pub fn bits_label_swapped(&self) -> u32[src]

Returns the bits of this message, but with the order of the 8 label bits reversed.

pub fn from_bits_label_swapped(bits: u32) -> Self[src]

Creates a message from a message representation with the 8 label bits reversed. The returned Message will be represented as transmitted on the wires.

pub fn check_parity(&self) -> Result<(), ParityError>[src]

Checks the parity of this message, and returns an error if the parity is not odd

Examples

assert!(Message::from(0x0).check_parity().is_err());
assert!(Message::from(0xf03ccccc).check_parity().is_err());
assert!(Message::from(0x1).check_parity().is_ok());
assert!(Message::from(0xf13ccccc).check_parity().is_ok());

pub fn update_parity(&self) -> Message[src]

Calculates the parity of this message and returns a new message with the parity bit (31) to the correct value

Examples

// Create a message with incorrect (even) parity
let message = Message::from(0x22443300);
assert_eq!(message.update_parity().bits(), 0xa2443300);
// Create a message with correct (odd) parity
let message = Message::from(0x22443301);
// Message should not change
assert_eq!(message.update_parity(), message);

pub fn label(&self) -> Label[src]

Returns the label of this message. This can be used to show the label as an octal number.

Examples

let message = Message::from(0x84000109);
let label = message.label();
assert_eq!(format!("{:?}", label), "Label(0o220)");
let message = Message::from(0x84000180);
let label = message.label();
assert_eq!(format!("{:?}", label), "Label(0o001)");

Trait Implementations

impl From<u32> for Message[src]

fn from(bits: u32) -> Self[src]

Creates a message from bits as transmitted, with no modifications

impl From<Message> for u32[src]

fn from(Message: Message) -> u32[src]

Converts a message into bits, with no modifications

impl Default for Message[src]

impl PartialEq<Message> for Message[src]

impl PartialOrd<Message> for Message[src]

impl Eq for Message[src]

impl Copy for Message[src]

impl Ord for Message[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl Clone for Message[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Message[src]

impl Hash for Message[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl Send for Message

impl Sync for Message

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.