pub trait DriverConnector: Send + Sync {
type Driver: Driver;
type Target: Sync;
type Authentication: Send + 'static;
type Error: Error + Send + Sync + 'static;
// Required method
fn connect<'a>(
&'a self,
target: &'a Self::Target,
authentication: Self::Authentication,
) -> impl Future<Output = Result<Self::Driver, Self::Error>> + Send + 'a;
}Expand description
Constructs and authenticates a provider-specific device driver.
A connector owns the protocol-specific connection process. The caller supplies authentication material it has already resolved; the connector never fetches credentials from a vault or another credential store.
Each provider chooses its own target, authentication, driver, and connection error types. The returned driver remains statically typed.
§Example
use network_device::{Driver, DriverConnector};
use std::convert::Infallible;
use std::future::Future;
struct Target { address: String }
struct Authentication { username: String, password: String }
struct DeviceDriver;
struct Connector;
impl Driver for DeviceDriver {
type Error = Infallible;
}
impl DriverConnector for Connector {
type Driver = DeviceDriver;
type Target = Target;
type Authentication = Authentication;
type Error = Infallible;
fn connect<'a>(
&'a self,
target: &'a Self::Target,
authentication: Self::Authentication,
) -> impl Future<Output = Result<Self::Driver, Self::Error>> + Send + 'a {
async move {
let _endpoint = &target.address;
let _username = authentication.username;
let _password = authentication.password;
Ok(DeviceDriver)
}
}
}Required Associated Types§
Sourcetype Authentication: Send + 'static
type Authentication: Send + 'static
Provider-defined, already-resolved authentication material.
Required Methods§
Sourcefn connect<'a>(
&'a self,
target: &'a Self::Target,
authentication: Self::Authentication,
) -> impl Future<Output = Result<Self::Driver, Self::Error>> + Send + 'a
fn connect<'a>( &'a self, target: &'a Self::Target, authentication: Self::Authentication, ) -> impl Future<Output = Result<Self::Driver, Self::Error>> + Send + 'a
Connects to the target and authenticates using the supplied material.
Authentication is passed by value so implementations can consume secrets without requiring a clone or shared ownership wrapper.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".