pub struct WrongFunctionCodeFault { /* private fields */ }Expand description
Corrupts the function code in Modbus response PDUs.
The function code is always at byte 0 of the PDU. This fault modifies that byte according to the configured mode.
§Modes
Fixed: Always use a specific function codeIncrement: Add 1 to the original FCRandom: Use a random FC (different from original)SwapRW: Swap between read FCs (01-04) and write FCs (05, 06, 0F, 10)
Implementations§
Source§impl WrongFunctionCodeFault
impl WrongFunctionCodeFault
Sourcepub fn new(mode: FcCorruptionMode, target: FaultTarget) -> Self
pub fn new(mode: FcCorruptionMode, target: FaultTarget) -> Self
Create a new wrong function code fault.
Sourcepub fn with_fixed_fc(self, fc: u8) -> Self
pub fn with_fixed_fc(self, fc: u8) -> Self
Set a fixed function code (for Fixed mode).
Sourcepub fn from_config(config: &FaultTypeConfig, target: FaultTarget) -> Self
pub fn from_config(config: &FaultTypeConfig, target: FaultTarget) -> Self
Create from config.
Trait Implementations§
Source§impl ModbusFault for WrongFunctionCodeFault
impl ModbusFault for WrongFunctionCodeFault
Source§fn fault_type(&self) -> &'static str
fn fault_type(&self) -> &'static str
Human-readable name of this fault type.
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Whether this fault is currently enabled.
Source§fn set_enabled(&self, enabled: bool)
fn set_enabled(&self, enabled: bool)
Enable or disable this fault.
Source§fn should_activate(&self, ctx: &ModbusFaultContext) -> bool
fn should_activate(&self, ctx: &ModbusFaultContext) -> bool
Check if this fault should activate for the given context.
This is called by the pipeline before
apply().Source§fn apply(&self, ctx: &ModbusFaultContext) -> FaultAction
fn apply(&self, ctx: &ModbusFaultContext) -> FaultAction
Apply the fault, returning the action to take. Read more
Source§fn stats(&self) -> FaultStatsSnapshot
fn stats(&self) -> FaultStatsSnapshot
Get a snapshot of this fault’s statistics.
Source§fn reset_stats(&self)
fn reset_stats(&self)
Reset all statistics counters.
Source§fn is_short_circuit(&self) -> bool
fn is_short_circuit(&self) -> bool
Whether this fault produces short-circuit actions (Drop/Partial).
Short-circuit faults are checked first in the pipeline.
Source§fn compatible_transport(&self) -> Option<TransportKind>
fn compatible_transport(&self) -> Option<TransportKind>
Transport compatibility.
Return
None to be compatible with all transports.Auto Trait Implementations§
impl !Freeze for WrongFunctionCodeFault
impl RefUnwindSafe for WrongFunctionCodeFault
impl Send for WrongFunctionCodeFault
impl Sync for WrongFunctionCodeFault
impl Unpin for WrongFunctionCodeFault
impl UnsafeUnpin for WrongFunctionCodeFault
impl UnwindSafe for WrongFunctionCodeFault
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