pub struct ModbusSimulator { /* private fields */ }Expand description
Device simulator wrapping a ModbusServer with preconfigured register maps.
Implementations§
Source§impl ModbusSimulator
impl ModbusSimulator
Sourcepub fn from_yaml(yaml: &str) -> Result<Self, SimError>
pub fn from_yaml(yaml: &str) -> Result<Self, SimError>
Create a simulator from a YAML configuration string.
§Errors
Returns SimError::ConfigParse if the YAML is invalid, or
SimError::Config if any configured block is out of range.
Sourcepub fn from_config(config: SimConfig) -> Result<Self, SimError>
pub fn from_config(config: SimConfig) -> Result<Self, SimError>
Create a simulator from a programmatic configuration.
§Errors
Returns SimError::Config if any configured block exceeds the Modbus
16-bit address space.
Sourcepub async fn start(&mut self) -> Result<SocketAddr, SimError>
pub async fn start(&mut self) -> Result<SocketAddr, SimError>
Start the simulator server. Returns the bound address.
§Errors
Returns SimError::Server if the server fails to start.
Sourcepub fn set_holding_register(
&self,
address: u16,
value: u16,
) -> Result<(), SimError>
pub fn set_holding_register( &self, address: u16, value: u16, ) -> Result<(), SimError>
Update a holding register at runtime.
Sourcepub fn set_input_register(
&self,
address: u16,
value: u16,
) -> Result<(), SimError>
pub fn set_input_register( &self, address: u16, value: u16, ) -> Result<(), SimError>
Update an input register at runtime.
Sourcepub fn set_coil(&self, address: u16, value: bool) -> Result<(), SimError>
pub fn set_coil(&self, address: u16, value: bool) -> Result<(), SimError>
Update a coil at runtime.
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ModbusSimulator
impl !UnwindSafe for ModbusSimulator
impl Freeze for ModbusSimulator
impl Send for ModbusSimulator
impl Sync for ModbusSimulator
impl Unpin for ModbusSimulator
impl UnsafeUnpin for ModbusSimulator
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