pub struct WriteSingleCoil {
pub addr: u16,
pub state: BitState,
}
Expand description
Request structure to write single coil
Fields§
§addr: u16
§state: BitState
Implementations§
Source§impl WriteSingleCoil
impl WriteSingleCoil
pub const MODBUS_FUNCTION_CODE: PublicModbusFunction = PublicModbusFunction::WriteSingleCoil
Sourcepub fn new(addr: u16, state: BitState) -> Self
pub fn new(addr: u16, state: BitState) -> 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 WriteSingleCoil
impl Clone for WriteSingleCoil
Source§fn clone(&self) -> WriteSingleCoil
fn clone(&self) -> WriteSingleCoil
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 WriteSingleCoil
impl Debug for WriteSingleCoil
Source§impl Default for WriteSingleCoil
impl Default for WriteSingleCoil
Source§fn default() -> WriteSingleCoil
fn default() -> WriteSingleCoil
Returns the “default value” for a type. Read more
Source§impl Hash for WriteSingleCoil
impl Hash for WriteSingleCoil
Source§impl Ord for WriteSingleCoil
impl Ord for WriteSingleCoil
Source§fn cmp(&self, other: &WriteSingleCoil) -> Ordering
fn cmp(&self, other: &WriteSingleCoil) -> 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 WriteSingleCoil
impl PartialEq for WriteSingleCoil
Source§impl PartialOrd for WriteSingleCoil
impl PartialOrd for WriteSingleCoil
impl Copy for WriteSingleCoil
impl Eq for WriteSingleCoil
impl StructuralPartialEq for WriteSingleCoil
Auto Trait Implementations§
impl Freeze for WriteSingleCoil
impl RefUnwindSafe for WriteSingleCoil
impl Send for WriteSingleCoil
impl Sync for WriteSingleCoil
impl Unpin for WriteSingleCoil
impl UnwindSafe for WriteSingleCoil
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