pub struct ModbusBuilder { /* private fields */ }Expand description
Builder for Modbus packets.
Supports three frame types:
- TCP (MBAP): Default. Adds a 7-byte MBAP header.
- RTU: Binary serial framing with CRC-16 appended.
- ASCII: Hex-encoded with ‘:’ prefix, LRC, and CRLF suffix.
Implementations§
Source§impl ModbusBuilder
impl ModbusBuilder
Sourcepub fn start_addr(self, addr: u16) -> Self
pub fn start_addr(self, addr: u16) -> Self
Set the Start Address (for Read/Write requests).
Sourcepub fn output_value(self, val: u16) -> Self
pub fn output_value(self, val: u16) -> Self
Set the Output Value (for Write Single Coil/Register).
Sourcepub fn values(self, vals: Vec<u16>) -> Self
pub fn values(self, vals: Vec<u16>) -> Self
Set register values (for Write Multiple Registers).
Sourcepub fn coil_values(self, vals: Vec<bool>) -> Self
pub fn coil_values(self, vals: Vec<bool>) -> Self
Set coil values (for Write Multiple Coils).
Sourcepub fn pdu_data(self, data: Vec<u8>) -> Self
pub fn pdu_data(self, data: Vec<u8>) -> Self
Set raw PDU data (after the function code). This overrides the automatic PDU building.
Sourcepub fn extra_data(self, data: Vec<u8>) -> Self
pub fn extra_data(self, data: Vec<u8>) -> Self
Set extra data bytes (for diagnostics data field, etc.).
Sourcepub fn header_size(&self) -> usize
pub fn header_size(&self) -> usize
Compute the header size for this builder.
Trait Implementations§
Source§impl Clone for ModbusBuilder
impl Clone for ModbusBuilder
Source§fn clone(&self) -> ModbusBuilder
fn clone(&self) -> ModbusBuilder
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 ModbusBuilder
impl Debug for ModbusBuilder
Source§impl Default for ModbusBuilder
impl Default for ModbusBuilder
Source§impl IntoLayerStackEntry for ModbusBuilder
impl IntoLayerStackEntry for ModbusBuilder
fn into_layer_stack_entry(self) -> LayerStackEntry
Auto Trait Implementations§
impl Freeze for ModbusBuilder
impl RefUnwindSafe for ModbusBuilder
impl Send for ModbusBuilder
impl Sync for ModbusBuilder
impl Unpin for ModbusBuilder
impl UnsafeUnpin for ModbusBuilder
impl UnwindSafe for ModbusBuilder
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