Struct can_type_rs::j1939::Pgn

source ·
pub struct Pgn(/* private fields */);
Expand description

Bitfield representation of 18-bit Parameter Group Number (PGN).

§Repr: u32

FieldSize (bits)
Padding bits (private)14
Reserved bits1
Data page bits1
PDU format bits8
PDU specific bits8

Implementations§

source§

impl Pgn

source

pub const fn new() -> Self

Creates a new default initialized bitfield.

source

pub const fn from_bits(bits: u32) -> Self

Convert from bits.

source

pub const fn into_bits(self) -> u32

Convert into bits.

source§

impl Pgn

source

pub const fn pdu_format(&self) -> PduFormat

Returns the PDU format based on the parsed bits.

§Returns
  • PduFormat::Pdu1(bits) if the PDU format value is less than 240.
  • PduFormat::Pdu2(bits) otherwise.
source

pub const fn group_extension(&self) -> GroupExtension

Returns the group extension based on the parsed bits.

§Returns
  • GroupExtension::None if the PDU format is Pdu1.
  • GroupExtension::Some(bits) if the PDU format is Pdu2.
source

pub const fn destination_address(&self) -> DestinationAddress

Returns the destination address based on the parsed PDU format.

§Returns
  • DestinationAddress::Some(bits) if the PDU format is Pdu1.
  • DestinationAddress::None if the PDU format is Pdu2.
source

pub const fn communication_mode(&self) -> CommunicationMode

Returns the communication mode based on the parsed PDU format.

§Returns
  • CommunicationMode::P2P if the PDU format is Pdu1.
  • CommunicationMode::Broadcast if the PDU format is Pdu2.
source

pub const fn is_p2p(&self) -> bool

Checks if the communication mode is point-to-point (P2P).

§Returns
  • true if the communication mode is P2P.
  • false if the communication mode is Broadcast.
source

pub const fn is_broadcast(&self) -> bool

Checks if the communication mode is broadcast.

§Returns
  • true if the communication mode is Broadcast.
  • false if the communication mode is P2P.
source

pub fn pdu_assignment(&self) -> PduAssignment

Determines the PDU assignment based on the parsed bits.

§Returns
  • PduAssignment::Sae(bits) for known SAE-defined PDU assignments.
  • PduAssignment::Manufacturer(bits) for manufacturer-defined PDU assignments.
  • PduAssignment::Unknown(bits) for unrecognized PDU assignments.

Trait Implementations§

source§

impl Clone for Pgn

source§

fn clone(&self) -> Pgn

Returns a copy 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 for Pgn

source§

fn from_bits(bits: u32) -> Self

Creates a new Pgn bitfield from a 32-bit integer.

source§

fn from_hex(hex_str: &str) -> Self

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

source§

fn try_from_bits(bits: u32) -> Option<Self>

Creates a new Pgn bitfield from a 32-bit integer.

source§

fn try_from_hex(hex_str: &str) -> Option<Self>

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

source§

fn into_bits(self) -> u32

Creates a new 32-bit integer from the Pgn bitfield.

source§

fn into_hex(self) -> String

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

§

type Type = u32

source§

impl Debug for Pgn

source§

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

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

impl Default for Pgn

source§

fn default() -> Self

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

impl From<Pgn> for u32

source§

fn from(v: Pgn) -> u32

Converts to this type from the input type.
source§

impl From<u32> for Pgn

source§

fn from(v: u32) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Pgn

source§

fn eq(&self, other: &Pgn) -> 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 Copy for Pgn

source§

impl Eq for Pgn

source§

impl StructuralPartialEq for Pgn

Auto Trait Implementations§

§

impl Freeze for Pgn

§

impl RefUnwindSafe for Pgn

§

impl Send for Pgn

§

impl Sync for Pgn

§

impl Unpin for Pgn

§

impl UnwindSafe for Pgn

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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>,

§

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>,

§

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.