pub trait Encode {
// Required methods
fn encode_into(&self, buf: &mut [u8]) -> Result<usize, EncodeError>;
fn encoded_len(&self) -> usize;
}Expand description
Trait for encoding a Modbus PDU into a byte buffer.
Required Methods§
Sourcefn 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.
Returns the number of bytes written on success.
§Errors
Returns EncodeError::BufferTooSmall if buf is shorter than
encoded_len. Returns EncodeError::PduTooLarge
if the encoded PDU would exceed the Modbus 253-byte ceiling.
Sourcefn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Total encoded length in bytes (including the function code byte).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".