pub struct WriteSingleCoilRequest {
pub address: Address,
pub value: CoilValue,
}Expand description
FC 0x05 — Write Single Coil request.
Sets a single coil at address to value (ON = 0xFF00, OFF = 0x0000).
Fields§
§address: AddressCoil address (0-indexed).
value: CoilValueCoil value (ON or OFF).
Implementations§
Source§impl WriteSingleCoilRequest
impl WriteSingleCoilRequest
Sourcepub fn decode(data: &[u8]) -> Result<Self, DecodeError>
pub fn decode(data: &[u8]) -> Result<Self, DecodeError>
Decode from PDU data after the function code byte.
§Errors
Returns DecodeError::Truncated if data is shorter than 4 bytes.
Returns DecodeError::LengthMismatch if data has extra bytes.
Returns DecodeError::InvalidCoilValue if the value is not 0xFF00 or 0x0000.
Trait Implementations§
Source§impl Clone for WriteSingleCoilRequest
impl Clone for WriteSingleCoilRequest
Source§fn clone(&self) -> WriteSingleCoilRequest
fn clone(&self) -> WriteSingleCoilRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for WriteSingleCoilRequest
Source§impl Debug for WriteSingleCoilRequest
impl Debug for WriteSingleCoilRequest
Source§impl Encode for WriteSingleCoilRequest
impl Encode for WriteSingleCoilRequest
Source§fn encode_into(&self, buf: &mut [u8]) -> Result<usize, EncodeError>
fn encode_into(&self, buf: &mut [u8]) -> Result<usize, EncodeError>
Write the full PDU (function code + data) into
buf. Read moreSource§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Total encoded length in bytes (including the function code byte).
impl Eq for WriteSingleCoilRequest
Source§impl PartialEq for WriteSingleCoilRequest
impl PartialEq for WriteSingleCoilRequest
Source§fn eq(&self, other: &WriteSingleCoilRequest) -> bool
fn eq(&self, other: &WriteSingleCoilRequest) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for WriteSingleCoilRequest
Auto Trait Implementations§
impl Freeze for WriteSingleCoilRequest
impl RefUnwindSafe for WriteSingleCoilRequest
impl Send for WriteSingleCoilRequest
impl Sync for WriteSingleCoilRequest
impl Unpin for WriteSingleCoilRequest
impl UnsafeUnpin for WriteSingleCoilRequest
impl UnwindSafe for WriteSingleCoilRequest
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