pub struct BackendConfig {
pub backend_name: String,
pub retry_count: Option<u32>,
pub retry_interval_ms: Option<u64>,
pub parameters: HashMap<String, Value>,
}Expand description
Backend configuration.
Contains the backend name and backend-specific parameters loaded from a TOML configuration file.
§Examples
use canlink_hal::BackendConfig;
let config = BackendConfig {
backend_name: "mock".to_string(),
retry_count: Some(3),
retry_interval_ms: Some(1000),
parameters: std::collections::HashMap::new(),
};
assert_eq!(config.backend_name, "mock");Fields§
§backend_name: StringBackend name (e.g., “TSMaster”, “mock”, “peak”)
retry_count: Option<u32>Number of initialization retry attempts (default: 3)
retry_interval_ms: Option<u64>Retry interval in milliseconds (default: 1000)
parameters: HashMap<String, Value>Backend-specific parameters
Implementations§
Source§impl BackendConfig
impl BackendConfig
Sourcepub fn new(backend_name: impl Into<String>) -> BackendConfig
pub fn new(backend_name: impl Into<String>) -> BackendConfig
Create a new backend configuration.
§Examples
use canlink_hal::BackendConfig;
let config = BackendConfig::new("mock");
assert_eq!(config.backend_name, "mock");Sourcepub fn get_parameter(&self, key: &str) -> Option<&Value>
pub fn get_parameter(&self, key: &str) -> Option<&Value>
Get a parameter value.
§Examples
use canlink_hal::BackendConfig;
let mut config = BackendConfig::new("mock");
config.parameters.insert("device_index".to_string(), toml::Value::Integer(0));
let value = config.get_parameter("device_index");
assert!(value.is_some());Sourcepub fn get_int(&self, key: &str) -> Option<i64>
pub fn get_int(&self, key: &str) -> Option<i64>
Get a parameter as an integer.
§Examples
use canlink_hal::BackendConfig;
let mut config = BackendConfig::new("mock");
config.parameters.insert("device_index".to_string(), toml::Value::Integer(0));
assert_eq!(config.get_int("device_index"), Some(0));Sourcepub fn get_string(&self, key: &str) -> Option<&str>
pub fn get_string(&self, key: &str) -> Option<&str>
Get a parameter as a string.
§Examples
use canlink_hal::BackendConfig;
let mut config = BackendConfig::new("mock");
config.parameters.insert("device".to_string(), toml::Value::String("can0".to_string()));
assert_eq!(config.get_string("device"), Some("can0"));Trait Implementations§
Source§impl Clone for BackendConfig
impl Clone for BackendConfig
Source§fn clone(&self) -> BackendConfig
fn clone(&self) -> BackendConfig
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 BackendConfig
impl Debug for BackendConfig
Source§impl<'de> Deserialize<'de> for BackendConfig
impl<'de> Deserialize<'de> for BackendConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BackendConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BackendConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for BackendConfig
impl Serialize for BackendConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for BackendConfig
impl RefUnwindSafe for BackendConfig
impl Send for BackendConfig
impl Sync for BackendConfig
impl Unpin for BackendConfig
impl UnsafeUnpin for BackendConfig
impl UnwindSafe for BackendConfig
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