pub trait BackendFactory: Send + Sync {
// Required methods
fn create(&self, config: &BackendConfig) -> CanResult<Box<dyn CanBackend>>;
fn name(&self) -> &str;
fn version(&self) -> BackendVersion;
}Expand description
Backend factory trait.
This trait defines the factory pattern for creating backend instances. Each backend implementation should provide a factory that implements this trait.
§Examples
ⓘ
use canlink_hal::{BackendFactory, BackendConfig};
struct MockBackendFactory;
impl BackendFactory for MockBackendFactory {
fn create(&self, config: &BackendConfig) -> CanResult<Box<dyn CanBackend>> {
Ok(Box::new(MockBackend::new()))
}
fn name(&self) -> &str {
"mock"
}
fn version(&self) -> BackendVersion {
BackendVersion::new(0, 1, 0)
}
}Required Methods§
Sourcefn create(&self, config: &BackendConfig) -> CanResult<Box<dyn CanBackend>>
fn create(&self, config: &BackendConfig) -> CanResult<Box<dyn CanBackend>>
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Get the factory name.
Returns the unique identifier for this backend type.
Sourcefn version(&self) -> BackendVersion
fn version(&self) -> BackendVersion
Get the factory version.
Returns the version of the backend implementation.