pub struct ClientConfig {
pub plc_addr: SocketAddr,
pub source: NodeAddress,
pub destination: NodeAddress,
pub timeout: Duration,
}Expand description
Configuration for creating a FINS client.
Fields§
§plc_addr: SocketAddrPLC IP address or hostname.
source: NodeAddressSource node address (this client).
destination: NodeAddressDestination node address (the PLC).
timeout: DurationCommunication timeout.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(plc_ip: Ipv4Addr, source_node: u8, dest_node: u8) -> Self
pub fn new(plc_ip: Ipv4Addr, source_node: u8, dest_node: u8) -> Self
Creates a new client configuration with minimal required parameters.
Uses default timeout and local node addresses.
§Arguments
plc_ip- PLC IP address (port defaults to 9600)source_node- Source node number (this client)dest_node- Destination node number (the PLC)
§Example
use omron_fins::ClientConfig;
use std::net::Ipv4Addr;
let config = ClientConfig::new(Ipv4Addr::new(192, 168, 1, 250), 1, 0);Sourcepub fn with_port(self, port: u16) -> Self
pub fn with_port(self, port: u16) -> Self
Sets a custom PLC port (default is 9600).
§Example
use omron_fins::ClientConfig;
use std::net::Ipv4Addr;
let config = ClientConfig::new(Ipv4Addr::new(192, 168, 1, 250), 1, 0)
.with_port(9601);Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets a custom timeout (default is 2 seconds).
§Example
use omron_fins::ClientConfig;
use std::net::Ipv4Addr;
use std::time::Duration;
let config = ClientConfig::new(Ipv4Addr::new(192, 168, 1, 250), 1, 0)
.with_timeout(Duration::from_secs(5));Sourcepub fn with_source_network(self, network: u8) -> Self
pub fn with_source_network(self, network: u8) -> Self
Sets custom source network/unit addresses.
§Example
use omron_fins::ClientConfig;
use std::net::Ipv4Addr;
let config = ClientConfig::new(Ipv4Addr::new(192, 168, 1, 250), 1, 0)
.with_source_network(1)
.with_source_unit(0);Sourcepub fn with_source_unit(self, unit: u8) -> Self
pub fn with_source_unit(self, unit: u8) -> Self
Sets custom source unit address.
Sourcepub fn with_dest_network(self, network: u8) -> Self
pub fn with_dest_network(self, network: u8) -> Self
Sets custom destination network/unit addresses.
Sourcepub fn with_dest_unit(self, unit: u8) -> Self
pub fn with_dest_unit(self, unit: u8) -> Self
Sets custom destination unit address.
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
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 moreAuto Trait Implementations§
impl Freeze for ClientConfig
impl RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnsafeUnpin for ClientConfig
impl UnwindSafe for ClientConfig
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