Struct Message

Source
pub struct Message<P: IsProtocol, U: IsDataUnit> { /* private fields */ }
Expand description

Represents a CAN message with its associated identifier (Id) and protocol data unit (Pdu).

Implementations§

Source§

impl Message<J1939, Data>

Source

pub fn from_parts(id: Id<J1939>, pdu: Pdu<Data>) -> Self

Constructs a new Message from its parts: a 29-bit J1939 identifier and pdu containing 64 bits of generic data.

§Arguments
  • id: An Id<J1939> representing the 29-bit identifier of the message.
  • pdu: A Pdu<Data> containing the payload or content of the message.
§Returns

A new Message instance initialized with the provided parts.

Source

pub fn into_parts(self) -> (Id<J1939>, Pdu<Data>)

Destructures the Message into its parts: a 29-bit J1939 identifier and pdu containing 64 bits of generic data.

§Returns

A tuple containing:

  • An Id<J1939> representing the 29-bit identifier.
  • A Pdu<Data> containing the payload or content of the message.
Source

pub fn try_from_bits(hex_id: u32, hex_pdu: u64) -> Result<Self, Error>

Constructs a new Message from raw bit representations of its components.

§Errors
  • If failed to construct the identifier field from bits
  • If failed to construct the pdu field from bits
Source

pub fn try_from_hex(hex_id: &str, hex_pdu: &str) -> Result<Self, Error>

Constructs a new Message from hexadecimal string representations of its components.

§Errors
  • If failed to construct the identifier field from hex
  • If failed to construct the pdu field from hex
Source

pub fn from_bits(hex_id: u32, hex_pdu: u64) -> Self

Constructs a new Message from raw bit representations of its components.

§Arguments
  • hex_id: A u32 representing the hexadecimal encoded 29-bit J1939 identifier.
  • hex_pdu: A u64 representing the hexadecimal encoded pdu.
§Returns

A new Message instance initialized with the decoded components.

Source

pub fn from_hex(hex_id: &str, hex_pdu: &str) -> Self

Constructs a new Message from hexadecimal string representations of its components.

§Arguments
  • hex_id: A &str representing the hexadecimal encoded 29-bit J1939 identifier.
  • hex_pdu: A &str representing the hexadecimal encoded pdu.
§Returns

A new Message instance initialized with the decoded components.

Source

pub fn id(&self) -> Id<J1939>

Retrieves the 29-bit J1939 identifier from the message.

§Returns

The Id<J1939> bitfield associated with the message.

Source

pub fn pdu(&self) -> Pdu<Data>

Retrieves the pdu from the message.

§Returns

The Pdu<Data> bitfield associated with the message.

Source§

impl Message<J1939, Name>

Source

pub fn from_parts(id: Id<J1939>, pdu: Pdu<Name>) -> Self

Constructs a new Message from its parts: an identifier and pdu.

§Arguments
  • id: An Id<J1939> representing the 29-bit identifier of the message.
  • pdu: A Pdu<Data> containing the payload or content of the message.
§Returns

A new Message instance initialized with the provided parts.

Source

pub fn into_parts(self) -> (Id<J1939>, Pdu<Name>)

Destructures the Message into its parts: an identifier and pdu.

§Returns

A tuple containing:

  • An Id<J1939> representing the 29-bit identifier.
  • A Pdu<Data> containing the payload or content of the message.
Source

pub fn try_from_bits(hex_id: u32, hex_pdu: u64) -> Result<Self, Error>

Constructs a new Message from raw bit representations of its components.

§Errors
  • If failed to construct the identifier field from bits
  • If failed to construct the pdu field from bits
Source

pub fn try_from_hex(hex_id: &str, hex_pdu: &str) -> Result<Self, Error>

Constructs a new Message from hexadecimal string representations of its components.

§Errors
  • If failed to construct the identifier field from hex
  • If failed to construct the pdu field from hex
Source

pub fn from_bits(hex_id: u32, hex_pdu: u64) -> Self

Constructs a new Message from raw bit representations of its components.

§Arguments
  • hex_id: A u32 representing the hexadecimal encoded 29-bit identifier.
  • hex_pdu: A u64 representing the hexadecimal encoded pdu.
§Returns

A new Message instance initialized with the decoded components.

Source

pub fn from_hex(hex_id: &str, hex_pdu: &str) -> Self

Constructs a new Message from hexadecimal string representations of its components.

§Arguments
  • hex_id: A &str representing the hexadecimal encoded 29-bit identifier.
  • hex_pdu: A &str representing the hexadecimal encoded pdu.
§Returns

A new Message instance initialized with the decoded components.

Source

pub fn id(&self) -> Id<J1939>

Retrieves the 29-bit identifier from the message.

§Returns

The Id<J1939> bitfield associated with the message.

Source

pub fn pdu(&self) -> Pdu<Name>

Retrieves the pdu from the message.

§Returns

The Pdu<Data> bitfield associated with the message.

Trait Implementations§

Source§

impl<P: Clone + IsProtocol, U: Clone + IsDataUnit> Clone for Message<P, U>

Source§

fn clone(&self) -> Message<P, U>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug + IsProtocol, U: Debug + IsDataUnit> Debug for Message<P, U>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Message<J1939, Data>> for Message<J1939, Name>

Source§

fn from(value: Message<J1939, Data>) -> Self

Converts to this type from the input type.
Source§

impl From<Message<J1939, Name>> for Message<J1939, Data>

Source§

fn from(value: Message<J1939, Name>) -> Self

Converts to this type from the input type.
Source§

impl<P: Ord + IsProtocol, U: Ord + IsDataUnit> Ord for Message<P, U>

Source§

fn cmp(&self, other: &Message<P, U>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<P: PartialEq + IsProtocol, U: PartialEq + IsDataUnit> PartialEq for Message<P, U>

Source§

fn eq(&self, other: &Message<P, U>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P: PartialOrd + IsProtocol, U: PartialOrd + IsDataUnit> PartialOrd for Message<P, U>

Source§

fn partial_cmp(&self, other: &Message<P, U>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<P: Copy + IsProtocol, U: Copy + IsDataUnit> Copy for Message<P, U>

Source§

impl<P: Eq + IsProtocol, U: Eq + IsDataUnit> Eq for Message<P, U>

Source§

impl<P: IsProtocol, U: IsDataUnit> StructuralPartialEq for Message<P, U>

Auto Trait Implementations§

§

impl<P, U> Freeze for Message<P, U>
where P: Freeze, U: Freeze,

§

impl<P, U> RefUnwindSafe for Message<P, U>

§

impl<P, U> Send for Message<P, U>
where P: Send, U: Send,

§

impl<P, U> Sync for Message<P, U>
where P: Sync, U: Sync,

§

impl<P, U> Unpin for Message<P, U>
where P: Unpin, U: Unpin,

§

impl<P, U> UnwindSafe for Message<P, U>
where P: UnwindSafe, U: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.