pub struct ModbusFunction(pub u8);
Expand description
A modbus function. This struct may store public as well as custom functions. The only invalid function is 0.
This structure is a new type wrapper over u8 which adds function code identification methods.
Tuple Fields§
§0: u8
Implementations§
Source§impl ModbusFunction
impl ModbusFunction
pub const fn new(function_code: u8) -> Self
Sourcepub const fn new_public(public_function: PublicModbusFunction) -> Self
pub const fn new_public(public_function: PublicModbusFunction) -> Self
Create a modbus function from a public Modbus function
Sourcepub const fn is(self, public_function: PublicModbusFunction) -> bool
pub const fn is(self, public_function: PublicModbusFunction) -> bool
Checks if this function matches the given public function
Sourcepub const fn is_public(self) -> bool
pub const fn is_public(self) -> bool
Checks if this function is a publicly documented modbus function.
This function returns true if this is a public reserved AND publicly documented function specified in the modbus spec
Sourcepub const fn is_public_reserved(self) -> bool
pub const fn is_public_reserved(self) -> bool
Checks if this function is a public reserved function. Any valid and non custom function is reserved.
Sourcepub const fn is_exception(self) -> bool
pub const fn is_exception(self) -> bool
Checks if this function code is an expection code. Which means that self >= 128
Sourcepub fn from_data(data: &[u8]) -> (Option<Self>, Option<&[u8]>)
pub fn from_data(data: &[u8]) -> (Option<Self>, Option<&[u8]>)
Gets the function code of the given modbus data.
None is returned if data contains less than 1 byte
Sourcepub unsafe fn from_data_unchecked(data: &[u8]) -> (Self, &[u8])
pub unsafe fn from_data_unchecked(data: &[u8]) -> (Self, &[u8])
Gets the function code of the given modbus data.
§Safety
Providing data with less than one byte is undefined behavior
Trait Implementations§
Source§impl Clone for ModbusFunction
impl Clone for ModbusFunction
Source§fn clone(&self) -> ModbusFunction
fn clone(&self) -> ModbusFunction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more