Struct Pdu

Source
pub struct Pdu<U: IsDataUnit>(/* private fields */);
Expand description

Represents a Protocol Data Unit (PDU) in the context of Controller Area Network (CAN).

Implementations§

Source§

impl Pdu<Data>

Source

pub const fn byte_0(self) -> u8

Retrieve byte 0.

Source

pub const fn byte_1(self) -> u8

Retrieve byte 1.

Source

pub const fn byte_2(self) -> u8

Retrieve byte 2.

Source

pub const fn byte_3(self) -> u8

Retrieve byte 3.

Source

pub const fn byte_4(self) -> u8

Retrieve byte 4.

Source

pub const fn byte_5(self) -> u8

Retrieve byte 5.

Source

pub const fn byte_6(self) -> u8

Retrieve byte 6.

Source

pub const fn byte_7(self) -> u8

Retrieve byte 7.

Source

pub const fn to_le_bytes(&self) -> [u8; 8]

Return the 64-bit Data bitfield as little-endian bytes.

Source

pub const fn to_be_bytes(&self) -> [u8; 8]

Return the 64-bit Data bitfield as big-endian bytes.

Source

pub const fn to_ne_bytes(&self) -> [u8; 8]

Return the 64-bit Data bitfield as native-endian bytes.

Source

pub const fn to_le(&self) -> Self

Convert the Data bitfield to little-endian byte format.

Source

pub const fn to_be(&self) -> Self

Convert the Data bitfield to big-endian byte format.

Source§

impl Pdu<Name>

Source

pub const fn arbitrary_address(&self) -> bool

Indicates whether or not the ECU/CA can negotiate an address (true = yes; false = no).

Source

pub const fn industry_group(&self) -> u8

These codes are associated with particular industries such as on-highway equipment, agricultural equipment, and more.

Source

pub const fn vehicle_system_instance(&self) -> u8

Assigns a number to each instance on the Vehicle System (in case you connect several networks – e.g. connecting cars on a train).

Source

pub const fn vehicle_system(&self) -> u8

Vehicle systems are associated with the Industry Group and they can be, for instance, “tractor” in the “Common” industry or “trailer” in the “On-Highway” industry group.

Source

pub const fn reserved(&self) -> bool

Always zero(false).

Source

pub const fn function(&self) -> u8

This code, in a range between 128 and 255, is assigned according to the Industry Group. A value between 0 and 127 is not associated with any other parameter.

Source

pub const fn function_instance(&self) -> u8

Returns the function instance.

Source

pub const fn ecu_instance(&self) -> u8

A J1939 network may accommodate several ECUs of the same kind (i.e. same functionality). The Instance code separates them.

Source

pub const fn manufacturer_code(&self) -> u16

The 11-Bit Manufacturer Code is assigned by the SAE.

Source

pub const fn identity_number(&self) -> u32

This field is assigned by the manufacturer, similar to a serial number, i.e. the code must be uniquely assigned to the unit.

Trait Implementations§

Source§

impl<U: Clone + IsDataUnit> Clone for Pdu<U>

Source§

fn clone(&self) -> Pdu<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 Conversion<u64> for Pdu<Data>

Source§

fn from_bits(bits: u64) -> Self

Creates a new Data bitfield from a 64-bit integer.

Source§

fn from_hex(hex_str: &str) -> Self

Creates a new Data bitfield from a base-16 (hex) string slice.

Source§

fn try_from_bits(bits: u64) -> Result<Self, Self::Error>

Creates a new Data bitfield from a 64-bit integer.

§Errors
  • Never (conversion is trivial)
Source§

fn try_from_hex(hex_str: &str) -> Result<Self, Self::Error>

Creates a new Data bitfield from a base-16 (hex) string slice.

§Errors
  • If failed to parse input hexadecimal string slice.
Source§

fn into_bits(self) -> u64

Creates a new 64-bit integer from the Data bitfield.

Source§

fn into_hex(self) -> String

Creates a new base-16 (hex) String from the Data bitfield.

§Requires
  • alloc
Source§

type Error = Error

Source§

impl Conversion<u64> for Pdu<Name>

Source§

fn from_bits(bits: u64) -> Self

Creates a new Name bitfield from a 64-bit integer.

Source§

fn from_hex(hex_str: &str) -> Self

Creates a new Name bitfield from a base-16 (hex) string slice.

Source§

fn try_from_bits(bits: u64) -> Result<Self, Self::Error>

Creates a new Name bitfield from a 64-bit integer.

§Errors
  • Never (conversion is trivial)
Source§

fn try_from_hex(hex_str: &str) -> Result<Self, Self::Error>

Creates a new Name bitfield from a base-16 (hex) string slice.

§Errors
  • If invalid encoding of provided Base16 string
  • If insufficient output buffer length
Source§

fn into_bits(self) -> u64

Creates a new 64-bit integer from the Name bitfield.

Source§

fn into_hex(self) -> String

Creates a new base-16 (hex) String from the Name bitfield.

§Requires
  • alloc
Source§

type Error = Error

Source§

impl<U: Debug + IsDataUnit> Debug for Pdu<U>

Source§

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

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

impl From<Pdu<Data>> for Pdu<Name>

Source§

fn from(value: Pdu<Data>) -> Self

Converts to this type from the input type.
Source§

impl From<Pdu<Name>> for Pdu<Data>

Source§

fn from(value: Pdu<Name>) -> Self

Converts to this type from the input type.
Source§

impl<U: Ord + IsDataUnit> Ord for Pdu<U>

Source§

fn cmp(&self, other: &Pdu<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<U: PartialEq + IsDataUnit> PartialEq for Pdu<U>

Source§

fn eq(&self, other: &Pdu<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<U: PartialOrd + IsDataUnit> PartialOrd for Pdu<U>

Source§

fn partial_cmp(&self, other: &Pdu<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<U: Copy + IsDataUnit> Copy for Pdu<U>

Source§

impl<U: Eq + IsDataUnit> Eq for Pdu<U>

Source§

impl<U: IsDataUnit> StructuralPartialEq for Pdu<U>

Auto Trait Implementations§

§

impl<U> Freeze for Pdu<U>
where U: Freeze,

§

impl<U> RefUnwindSafe for Pdu<U>
where U: RefUnwindSafe,

§

impl<U> Send for Pdu<U>
where U: Send,

§

impl<U> Sync for Pdu<U>
where U: Sync,

§

impl<U> Unpin for Pdu<U>
where U: Unpin,

§

impl<U> UnwindSafe for Pdu<U>
where 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.