Trait foxbox_taxonomy::adapter::AdapterManagerHandle [] [src]

pub trait AdapterManagerHandle: Send {
    fn add_adapter(&self, adapter: Arc<Adapter>) -> Result<(), Error>;
    fn remove_adapter(&self, id: &Id<AdapterId>) -> Result<(), Error>;
    fn add_service(&self, service: Service) -> Result<(), Error>;
    fn remove_service(&self, service_id: &Id<ServiceId>) -> Result<(), Error>;
    fn add_getter(&self, setter: Channel<Getter>) -> Result<(), Error>;
    fn remove_getter(&self, id: &Id<Getter>) -> Result<(), Error>;
    fn add_setter(&self, setter: Channel<Setter>) -> Result<(), Error>;
    fn remove_setter(&self, id: &Id<Setter>) -> Result<(), Error>;
}

An API that adapter managers must implement

Required Methods

fn add_adapter(&self, adapter: Arc<Adapter>) -> Result<(), Error>

Add an adapter to the system.

This version is optimized for Adapters that already implement Sync.

Errors

Returns an error if an adapter with the same id is already present.

fn remove_adapter(&self, id: &Id<AdapterId>) -> Result<(), Error>

Remove an adapter from the system, including all its services and channels.

Errors

Returns an error if no adapter with this identifier exists. Otherwise, attempts to cleanup as much as possible, even if for some reason the system is in an inconsistent state.

fn add_service(&self, service: Service) -> Result<(), Error>

Add a service to the system. Called by the adapter when a new service (typically a new device) has been detected/configured.

Requirements

The adapter is in charge of making sure that identifiers persist across reboots.

Errors

Returns an error if any of: - service has channels; - a service with id service.id is already installed on the system; - there is no adapter with id service.lock.

fn remove_service(&self, service_id: &Id<ServiceId>) -> Result<(), Error>

Remove a service previously registered on the system. Typically, called by an adapter when a service (e.g. a device) is disconnected.

Errors

Returns an error if any of: - there is no such service; - there is an internal inconsistency, in which case this method will still attempt to cleanup before returning an error.

fn add_getter(&self, setter: Channel<Getter>) -> Result<(), Error>

Add a setter to the system. Typically, this is called by the adapter when a new service has been detected/configured. Some services may gain/lose getters at runtime depending on their configuration.

Requirements

The adapter is in charge of making sure that identifiers persist across reboots.

Errors

Returns an error if the adapter is not registered, the parent service is not registered, or a channel with the same identifier is already registered. In either cases, this method reverts all its changes.

fn remove_getter(&self, id: &Id<Getter>) -> Result<(), Error>

Remove a setter previously registered on the system. Typically, called by an adapter when a service is reconfigured to remove one of its getters.

Error

This method returns an error if the setter is not registered or if the service is not registered. In either case, it attemps to clean as much as possible, even if the state is inconsistent.

fn add_setter(&self, setter: Channel<Setter>) -> Result<(), Error>

Add a setter to the system. Typically, this is called by the adapter when a new service has been detected/configured. Some services may gain/lose setters at runtime depending on their configuration.

Requirements

The adapter is in charge of making sure that identifiers persist across reboots.

Errors

Returns an error if the adapter is not registered, the parent service is not registered, or a channel with the same identifier is already registered. In either cases, this method reverts all its changes.

fn remove_setter(&self, id: &Id<Setter>) -> Result<(), Error>

Remove a setter previously registered on the system. Typically, called by an adapter when a service is reconfigured to remove one of its setters.

Error

This method returns an error if the setter is not registered or if the service is not registered. In either case, it attemps to clean as much as possible, even if the state is inconsistent.

Implementors