pub struct CanlinkConfig {
pub backend: BackendConfig,
}Expand description
Complete configuration file structure.
Represents the top-level structure of a canlink.toml configuration file.
§Examples
[backend]
backend_name = "mock"
retry_count = 3
retry_interval_ms = 1000
device_index = 0Fields§
§backend: BackendConfigBackend configuration
Implementations§
Source§impl CanlinkConfig
impl CanlinkConfig
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self, CanError>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self, CanError>
Load configuration from a TOML file.
§Arguments
path- Path to the TOML configuration file
§Errors
Returns CanError::ConfigError if the file cannot be read or parsed.
§Examples
use canlink_hal::CanlinkConfig;
let config = CanlinkConfig::from_file("canlink.toml").unwrap();
println!("Backend: {}", config.backend.backend_name);Sourcepub fn parse_toml(s: &str) -> Result<Self, CanError>
pub fn parse_toml(s: &str) -> Result<Self, CanError>
Sourcepub fn with_backend(backend_name: impl Into<String>) -> Self
pub fn with_backend(backend_name: impl Into<String>) -> Self
Create a default configuration with the specified backend.
§Examples
use canlink_hal::CanlinkConfig;
let config = CanlinkConfig::with_backend("mock");
assert_eq!(config.backend.backend_name, "mock");Trait Implementations§
Source§impl Clone for CanlinkConfig
impl Clone for CanlinkConfig
Source§fn clone(&self) -> CanlinkConfig
fn clone(&self) -> CanlinkConfig
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 CanlinkConfig
impl Debug for CanlinkConfig
Source§impl<'de> Deserialize<'de> for CanlinkConfig
impl<'de> Deserialize<'de> for CanlinkConfig
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 CanlinkConfig
impl RefUnwindSafe for CanlinkConfig
impl Send for CanlinkConfig
impl Sync for CanlinkConfig
impl Unpin for CanlinkConfig
impl UnsafeUnpin for CanlinkConfig
impl UnwindSafe for CanlinkConfig
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