Skip to main content

Mti

Struct Mti 

Source
pub struct Mti(pub u16);
Expand description

A 16-bit OpenLCB Message Type Indicator.

The associated constants name every MTI the crate decodes into a dedicated Message variant. Other values can still be built with Mti(0x…) and are carried by Message::Other.

Tuple Fields§

§0: u16

Implementations§

Source§

impl Mti

Source

pub const INITIALIZATION_COMPLETE: Mti

Initialization Complete (global). Sent once by a node after it has finished logging in; carries the 6-byte Node ID.

Source

pub const INITIALIZATION_COMPLETE_SIMPLE: Mti

Initialization Complete from a node that implements only the Simple Protocol subset.

Source

pub const VERIFY_NODE_ID_ADDRESSED: Mti

Verify Node ID, addressed to one node. Optional Node ID payload.

Source

pub const VERIFY_NODE_ID_GLOBAL: Mti

Verify Node ID, global: “everyone (or the node with this ID) please announce yourself”. Optional Node ID payload.

Source

pub const VERIFIED_NODE_ID: Mti

Verified Node ID (global): the answer to Verify Node ID, carrying the responder’s Node ID.

Source

pub const VERIFIED_NODE_ID_SIMPLE: Mti

Verified Node ID from a Simple Protocol node.

Source

pub const OPTIONAL_INTERACTION_REJECTED: Mti

Optional Interaction Rejected (addressed): the receiver does not support or cannot handle the request. Payload is an error code (see error_code) and the MTI being rejected.

Source

pub const TERMINATE_DUE_TO_ERROR: Mti

Terminate Due To Error (addressed): an interaction was aborted. Payload is an error code and the related MTI.

Source

pub const PROTOCOL_SUPPORT_INQUIRY: Mti

Protocol Support Inquiry (addressed): “which protocols do you speak?”

Source

pub const PROTOCOL_SUPPORT_REPLY: Mti

Protocol Support Reply (addressed): a bit field of supported protocols, see crate::message::protocol.

Source

pub const IDENTIFY_CONSUMER: Mti

Identify Consumer (global, with event): “who consumes this event?”

Source

pub const CONSUMER_RANGE_IDENTIFIED: Mti

Consumer Range Identified: the sender consumes a whole range of events, encoded as a mask in the low-order bits of the Event ID.

Source

pub const CONSUMER_IDENTIFIED_VALID: Mti

Consumer Identified, state Valid.

Source

pub const CONSUMER_IDENTIFIED_INVALID: Mti

Consumer Identified, state Invalid.

Source

pub const CONSUMER_IDENTIFIED_UNKNOWN: Mti

Consumer Identified, state Unknown.

Source

pub const IDENTIFY_PRODUCER: Mti

Identify Producer (global, with event): “who produces this event?” Also used by the Train Search Standard (see traction::search).

Source

pub const PRODUCER_RANGE_IDENTIFIED: Mti

Producer Range Identified: the sender produces a range of events.

Source

pub const PRODUCER_IDENTIFIED_VALID: Mti

Producer Identified, state Valid.

Source

pub const PRODUCER_IDENTIFIED_INVALID: Mti

Producer Identified, state Invalid.

Source

pub const PRODUCER_IDENTIFIED_UNKNOWN: Mti

Producer Identified, state Unknown.

Source

pub const IDENTIFY_EVENTS_ADDRESSED: Mti

Identify Events (addressed): “tell me everything you produce and consume”.

Source

pub const IDENTIFY_EVENTS_GLOBAL: Mti

Identify Events (global): every node lists all its events.

Source

pub const LEARN_EVENT: Mti

Learn Event: teaching message used by blue/gold button configuration.

Source

pub const PCER: Mti

Producer/Consumer Event Report: “this event just happened”.

Source

pub const TRACTION_CONTROL_COMMAND: Mti

Traction Control Command (addressed, throttle → train), defined by the Traction Control Standard. See crate::traction::Command.

Source

pub const TRACTION_CONTROL_REPLY: Mti

Traction Control Reply (addressed, train → throttle). See crate::traction::Reply.

Source

pub const SNIP_REQUEST: Mti

Simple Node Information Request (addressed), from the Simple Node Information Standard.

Source

pub const SNIP_REPLY: Mti

Simple Node Information Reply (addressed, multi-frame). Payload format in NodeInfo::snip_payload.

Source

pub const DATAGRAM: Mti

Datagram (addressed, up to 72 bytes), from the Datagram Transport Standard. On CAN it uses datagram frame types instead of a CAN-MTI.

Source

pub const DATAGRAM_RECEIVED_OK: Mti

Datagram Received OK (addressed). Optional one-byte flags field.

Source

pub const DATAGRAM_REJECTED: Mti

Datagram Rejected (addressed), with an error_code.

Source

pub const fn is_addressed(self) -> bool

True if the message carries a destination (addressed message).

This is bit 3 (0x0008) of the MTI. On CAN, addressed messages put the 12-bit destination alias in the first two data bytes; see Message::to_frames.

Source

pub const fn has_event(self) -> bool

True if the message carries an Event ID (bit 2, 0x0004).

Source

pub const fn can_mti(self) -> u16

The 12-bit value carried in the CAN header for this MTI.

This is simply the low 12 bits. It is only meaningful for MTIs sent in global/addressed frames (frame type 1); Mti::DATAGRAM uses datagram frame types instead. MTIs with bit 12 set do not fit; see Message::try_to_frames.

Source

pub fn name(self) -> &'static str

A short human readable name, for logging ("Unknown" for MTIs without a constant). Display prints the name and the hex value.

Source

pub const fn from_can_mti(v: u16) -> Mti

Map a 12-bit CAN-MTI back to the full MTI. All MTIs that are sent in CAN “global/addressed” frames fit in 12 bits, so this is the identity.

Trait Implementations§

Source§

impl Clone for Mti

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Mti

Source§

impl Debug for Mti

Source§

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

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

impl Display for Mti

Source§

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

PCER (0x05B4), or Unknown (0x0DA8) for MTIs without a constant.

assert_eq!(rolcb::Mti::PCER.to_string(), "PCER (0x05B4)");
Source§

impl Eq for Mti

Source§

impl Hash for Mti

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Mti

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Mti

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Mti

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 StructuralPartialEq for Mti

Auto Trait Implementations§

§

impl Freeze for Mti

§

impl RefUnwindSafe for Mti

§

impl Send for Mti

§

impl Sync for Mti

§

impl Unpin for Mti

§

impl UnsafeUnpin for Mti

§

impl UnwindSafe for Mti

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.