Skip to main content

NodeInfo

Struct NodeInfo 

Source
pub struct NodeInfo {
    pub manufacturer: String,
    pub model: String,
    pub hardware_version: String,
    pub software_version: String,
    pub user_name: String,
    pub user_description: String,
}
Expand description

Simple Node Information, reported to configuration tools such as JMRI.

The Simple Node Information Standard (SNIP) lets a tool ask any node for six human-readable strings without reading its configuration memory. The first four are fixed by the manufacturer; the last two are set by the user (JMRI shows them as the node’s name and description). Node answers SNIP requests from its NodeInfo automatically.

Wire format of the reply payload:

 0x04                        manufacturer section version
 manufacturer \0             max 41 bytes incl. NUL
 model \0                    max 41
 hardware_version \0         max 21
 software_version \0         max 21
 0x02                        user section version
 user_name \0                max 63
 user_description \0         max 64
use rolcb::NodeInfo;

let info = NodeInfo {
    manufacturer: "Uncommon Models".into(),
    model: "Dispatch Panel".into(),
    software_version: "0.1.0".into(),
    user_name: "Yard tower".into(),
    ..Default::default()
};
let bytes = info.snip_payload();
assert_eq!(bytes[0], 4);
assert_eq!(NodeInfo::from_snip(&bytes), info);

Fields§

§manufacturer: String

Manufacturer name (truncated to 40 bytes on the wire).

§model: String

Model name (truncated to 40 bytes).

§hardware_version: String

Hardware version (truncated to 20 bytes).

§software_version: String

Software version (truncated to 20 bytes).

§user_name: String

User-assigned node name (truncated to 62 bytes).

§user_description: String

User-assigned description (truncated to 63 bytes).

Implementations§

Source§

impl NodeInfo

Source

pub fn snip_payload(&self) -> Vec<u8> ⓘ

Encode as a SNIP reply payload.

Over-long strings are truncated at a UTF-8 character boundary to fit the field limits shown in the type docs.

Source

pub fn from_snip(p: &[u8]) -> NodeInfo

Decode a SNIP reply payload (lenient).

The two version bytes are skipped without checking, missing fields become empty strings and invalid UTF-8 is replaced with U+FFFD, so this never fails.

Trait Implementations§

Source§

impl Clone for NodeInfo

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 Debug for NodeInfo

Source§

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

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

impl Default for NodeInfo

Source§

fn default() -> Self

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

impl Eq for NodeInfo

Source§

impl PartialEq for NodeInfo

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 StructuralPartialEq for NodeInfo

Auto Trait Implementations§

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 = !

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.