pub trait Driver:
Sized
+ Send
+ Sync
+ 'static {
const NAME: &str;
// Required methods
fn start(
context: DriverContext,
) -> impl Future<Output = Result<Self, Status>> + Send;
fn stop(&self) -> impl Future<Output = ()> + Send;
}
Expand description
Entry points into a driver for starting and stopping.
Driver authors should implement this trait, taking information from the DriverContext
passed to the Driver::start
method to set up, and then tearing down any resources they use
in the Driver::stop
method.
Required Associated Constants§
Required Methods§
Sourcefn start(
context: DriverContext,
) -> impl Future<Output = Result<Self, Status>> + Send
fn start( context: DriverContext, ) -> impl Future<Output = Result<Self, Status>> + Send
This will be called when the driver is started.
The given DriverContext
contains information and functionality necessary to get at the
driver’s incoming and outgoing namespaces, add child nodes in the driver topology, and
manage dispatchers.
In order for the driver to be properly considered started, it must return [Status::OK
]
and bind the client end for the [DriverStartArgs::node
] given in
DriverContext::start_args
.
Sourcefn stop(&self) -> impl Future<Output = ()> + Send
fn stop(&self) -> impl Future<Output = ()> + Send
This will be called when the driver has been asked to stop, and should do any asynchronous cleanup necessary before the driver is fully shut down.
Note: The driver will not be considered fully stopped until the node client end bound in
Driver::start
has been closed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.