Skip to main content

BackendConfig

Struct BackendConfig 

Source
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: String

Backend 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

Source

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");
Source

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());
Source

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));
Source

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"));
Source

pub fn get_bool(&self, key: &str) -> Option<bool>

Get a parameter as a boolean.

§Examples
use canlink_hal::BackendConfig;

let mut config = BackendConfig::new("mock");
config.parameters.insert("canfd".to_string(), toml::Value::Boolean(true));

assert_eq!(config.get_bool("canfd"), Some(true));

Trait Implementations§

Source§

impl Clone for BackendConfig

Source§

fn clone(&self) -> BackendConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BackendConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BackendConfig

Source§

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

Source§

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,