Skip to main content

DataType

Enum DataType 

Source
#[non_exhaustive]
pub enum DataType {
Show 14 variants Boolean = 1, Integer8 = 2, Integer16 = 3, Integer32 = 4, Unsigned8 = 5, Unsigned16 = 6, Unsigned32 = 7, Real32 = 8, Real64 = 17, Integer64 = 21, Unsigned64 = 27, VisibleString = 9, OctetString = 10, Domain = 15,
}
Expand description

A CANopen basic data type.

The discriminant is the CiA 301 data type index (the object index under which the type is described, e.g. UNSIGNED32 is 0x0007).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Boolean = 1

BOOLEAN (0x0001), 1 byte.

§

Integer8 = 2

INTEGER8 (0x0002), 1 byte.

§

Integer16 = 3

INTEGER16 (0x0003), 2 bytes.

§

Integer32 = 4

INTEGER32 (0x0004), 4 bytes.

§

Unsigned8 = 5

UNSIGNED8 (0x0005), 1 byte.

§

Unsigned16 = 6

UNSIGNED16 (0x0006), 2 bytes.

§

Unsigned32 = 7

UNSIGNED32 (0x0007), 4 bytes.

§

Real32 = 8

REAL32 (0x0008), 4 bytes.

§

Real64 = 17

REAL64 (0x0011), 8 bytes.

§

Integer64 = 21

INTEGER64 (0x0015), 8 bytes.

§

Unsigned64 = 27

UNSIGNED64 (0x001B), 8 bytes.

§

VisibleString = 9

VISIBLE_STRING (0x0009), variable length (ASCII/UTF-8 text).

§

OctetString = 10

OCTET_STRING (0x000A), variable length (arbitrary bytes).

§

Domain = 15

DOMAIN (0x000F), variable length (arbitrary bytes).

Implementations§

Source§

impl DataType

Source

pub const fn index(self) -> u16

The CiA 301 data type index (e.g. 0x0007 for UNSIGNED32).

Source

pub const fn from_index(index: u16) -> Option<Self>

The basic data type for a CiA 301 data type index, or None for an index this crate does not model.

Source

pub const fn fixed_size(self) -> Option<usize>

The fixed encoded size of a value of this type in bytes, or None for a variable-length type (VISIBLE_STRING, OCTET_STRING, DOMAIN).

Source

pub const fn is_variable(self) -> bool

Whether this is a variable-length type.

Source

pub const fn size(self) -> usize

The fixed encoded size of a value of this type in bytes, or 0 for a variable-length type (whose size depends on the value — see fixed_size).

Trait Implementations§

Source§

impl Clone for DataType

Source§

fn clone(&self) -> DataType

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 DataType

Source§

impl Debug for DataType

Source§

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

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

impl Eq for DataType

Source§

impl PartialEq for DataType

Source§

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

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