Skip to main content

AnyDev

Trait AnyDev 

Source
pub trait AnyDev:
    Debug
    + Send
    + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn class(&self) -> &dyn AnyClass;
    fn init(&self) -> BoxFuture<'_, Result<()>>;
    fn withdraw(&self) -> BoxFuture<'_, Result<()>>;
    fn serve(&self) -> Result<Arc<str>>;
}
Expand description

The model-erased view of a Dev, which is how a server refers to the devices it serves, whatever the model of the class they belong to.

Required Methods§

Source

fn name(&self) -> &str

The name of that device.

Source

fn class(&self) -> &dyn AnyClass

The class of that device.

Source

fn init(&self) -> BoxFuture<'_, Result<()>>

Initialize that device: its model, if it has one, is deleted, and a new one is built by the init function of its class, on the pool of the server when that may block. This only fails when the initialization never ran to its end, its function having panicked: one that failed is kept by the device instead.

Source

fn withdraw(&self) -> BoxFuture<'_, Result<()>>

Stop serving that device, for good, and delete its model, if it has one, giving it back to the delete function of its class so that it may release what it owns: what a device goes through once it is removed from its server, or when the server shuts down. Not to be confused with the deletion of the model alone, which is also what an initialization starts with, see Dev::init.

The backend is told first, so that no new request reaches a device that is being deleted, see crate::backend::BackendServer::remove. A request it was answering may still be running, and the model is only deleted once it is through with it, which is why a request of that device must never wait for this.

Source

fn serve(&self) -> Result<Arc<str>>

Start serving that device through the backend of its server, giving back the ITR it is reached at. This is quick and never blocks, see crate::backend::BackendServer::add.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<M: Model> AnyDev for Dev<M>