pub struct RtuCodec { /* private fields */ }Expand description
Modbus RTU codec.
This codec handles the encoding and decoding of RTU frames with proper timing-based frame detection.
§Example
use mabi_modbus::rtu::{RtuCodec, RtuTiming};
use tokio_util::codec::Framed;
// Create codec with default timing (9600 baud)
let codec = RtuCodec::new();
// Create codec with custom timing
let codec = RtuCodec::with_timing(RtuTiming::from_baud_rate(115200));Implementations§
Source§impl RtuCodec
impl RtuCodec
Sourcepub fn with_timing(timing: RtuTiming) -> Self
pub fn with_timing(timing: RtuTiming) -> Self
Create a codec with specific timing configuration.
Sourcepub fn with_baud_rate(baud_rate: u32) -> Self
pub fn with_baud_rate(baud_rate: u32) -> Self
Create a codec for a specific baud rate.
Sourcepub fn strict_timing(self, enabled: bool) -> Self
pub fn strict_timing(self, enabled: bool) -> Self
Enable strict timing-based frame detection.
Sourcepub fn unit_id_filter(self, unit_ids: Vec<u8>) -> Self
pub fn unit_id_filter(self, unit_ids: Vec<u8>) -> Self
Set unit ID filter.
Only frames with matching unit IDs will be accepted.
Trait Implementations§
Source§impl Decoder for RtuCodec
impl Decoder for RtuCodec
Source§type Error = ModbusError
type Error = ModbusError
The type of unrecoverable frame decoding errors. Read more
Source§fn decode(
&mut self,
src: &mut BytesMut,
) -> Result<Option<Self::Item>, Self::Error>
fn decode( &mut self, src: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
Auto Trait Implementations§
impl Freeze for RtuCodec
impl RefUnwindSafe for RtuCodec
impl Send for RtuCodec
impl Sync for RtuCodec
impl Unpin for RtuCodec
impl UnsafeUnpin for RtuCodec
impl UnwindSafe for RtuCodec
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