pub struct WriteSingleRegister {
pub addr: u16,
pub value: u16,
}Expand description
Request structure to write single register
Fields§
§addr: u16§value: u16Implementations§
Source§impl WriteSingleRegister
impl WriteSingleRegister
pub const MODBUS_FUNCTION_CODE: PublicModbusFunction = PublicModbusFunction::WriteSingleRegister
Sourcepub fn new(addr: u16, value: u16) -> Self
pub fn new(addr: u16, value: u16) -> Self
Create a new request to write a single coil at addr and set it to state
Sourcepub fn from_data(data: &[u8]) -> Result<(Self, &[u8]), ModbusSerializationError>
pub fn from_data(data: &[u8]) -> Result<(Self, &[u8]), ModbusSerializationError>
Parse this request from the given modbus data
The data should only consist out of the address and quantity as the slave id function will be already read through other means.
Sourcepub unsafe fn from_data_unchecked(
data: &[u8],
) -> Result<(Self, &[u8]), ModbusSerializationError>
pub unsafe fn from_data_unchecked( data: &[u8], ) -> Result<(Self, &[u8]), ModbusSerializationError>
Parse this request from the given modbus data without bounds checks.
The data should only consist out of the address and quantity as the slave id function will be already read through other means.
§Safety
This function causes undefined behavior if the len of data is smaller than 4
pub fn into_data(self) -> [u8; 5]
Sourcepub fn write_to_slice(
self,
out: &mut [u8],
) -> Result<(), ModbusSerializationError>
pub fn write_to_slice( self, out: &mut [u8], ) -> Result<(), ModbusSerializationError>
Write this request to the slice as modbus data
Sourcepub unsafe fn write_to_slice_unchecked(self, out: &mut [u8])
pub unsafe fn write_to_slice_unchecked(self, out: &mut [u8])
Write this request to the slice as modbus data without bounds checking.
§Safety
This function invokes undefined behavior if the len of data is less than 5
Trait Implementations§
Source§impl Clone for WriteSingleRegister
impl Clone for WriteSingleRegister
Source§fn clone(&self) -> WriteSingleRegister
fn clone(&self) -> WriteSingleRegister
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WriteSingleRegister
impl Debug for WriteSingleRegister
Source§impl Default for WriteSingleRegister
impl Default for WriteSingleRegister
Source§fn default() -> WriteSingleRegister
fn default() -> WriteSingleRegister
Returns the “default value” for a type. Read more
Source§impl Hash for WriteSingleRegister
impl Hash for WriteSingleRegister
Source§impl Ord for WriteSingleRegister
impl Ord for WriteSingleRegister
Source§fn cmp(&self, other: &WriteSingleRegister) -> Ordering
fn cmp(&self, other: &WriteSingleRegister) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for WriteSingleRegister
impl PartialEq for WriteSingleRegister
Source§impl PartialOrd for WriteSingleRegister
impl PartialOrd for WriteSingleRegister
impl Copy for WriteSingleRegister
impl Eq for WriteSingleRegister
impl StructuralPartialEq for WriteSingleRegister
Auto Trait Implementations§
impl Freeze for WriteSingleRegister
impl RefUnwindSafe for WriteSingleRegister
impl Send for WriteSingleRegister
impl Sync for WriteSingleRegister
impl Unpin for WriteSingleRegister
impl UnwindSafe for WriteSingleRegister
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more