pub struct UnitConfig {
pub name: String,
pub description: String,
pub word_order: Option<WordOrder>,
pub register_config: Option<RegisterStoreConfig>,
pub broadcast_enabled: bool,
pub response_delay_us: u64,
pub enabled: bool,
pub metadata: HashMap<String, String>,
}Expand description
Configuration for a single Modbus unit.
Fields§
§name: StringHuman-readable name for this unit.
description: StringOptional description.
word_order: Option<WordOrder>Word order for this unit (overrides manager default).
register_config: Option<RegisterStoreConfig>Register store configuration for this unit.
broadcast_enabled: boolWhether this unit responds to broadcasts.
response_delay_us: u64Response delay in microseconds (for simulation).
enabled: boolWhether this unit is enabled.
metadata: HashMap<String, String>Custom metadata for this unit.
Implementations§
Source§impl UnitConfig
impl UnitConfig
Sourcepub fn with_word_order(name: impl Into<String>, word_order: WordOrder) -> Self
pub fn with_word_order(name: impl Into<String>, word_order: WordOrder) -> Self
Create a unit config with a specific word order.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the description.
Sourcepub fn with_register_config(self, config: RegisterStoreConfig) -> Self
pub fn with_register_config(self, config: RegisterStoreConfig) -> Self
Set the register configuration.
Sourcepub fn with_response_delay_us(self, delay: u64) -> Self
pub fn with_response_delay_us(self, delay: u64) -> Self
Set the response delay.
Sourcepub fn with_broadcast(self, enabled: bool) -> Self
pub fn with_broadcast(self, enabled: bool) -> Self
Set broadcast enabled state.
Sourcepub fn with_enabled(self, enabled: bool) -> Self
pub fn with_enabled(self, enabled: bool) -> Self
Set enabled state.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add metadata.
Sourcepub fn effective_word_order(&self, default: WordOrder) -> WordOrder
pub fn effective_word_order(&self, default: WordOrder) -> WordOrder
Get the effective word order (unit-specific or None for manager default).
Trait Implementations§
Source§impl Clone for UnitConfig
impl Clone for UnitConfig
Source§fn clone(&self) -> UnitConfig
fn clone(&self) -> UnitConfig
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 UnitConfig
impl Debug for UnitConfig
Source§impl Default for UnitConfig
impl Default for UnitConfig
Source§impl<'de> Deserialize<'de> for UnitConfig
impl<'de> Deserialize<'de> for UnitConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for UnitConfig
impl RefUnwindSafe for UnitConfig
impl Send for UnitConfig
impl Sync for UnitConfig
impl Unpin for UnitConfig
impl UnsafeUnpin for UnitConfig
impl UnwindSafe for UnitConfig
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