Trait splinter::service::Service[][src]

pub trait Service: Send {
    fn service_id(&self) -> &str;
fn service_type(&self) -> &str;
fn start(
        &mut self,
        service_registry: &dyn ServiceNetworkRegistry
    ) -> Result<(), ServiceStartError>;
fn stop(
        &mut self,
        service_registry: &dyn ServiceNetworkRegistry
    ) -> Result<(), ServiceStopError>;
fn destroy(self: Box<Self>) -> Result<(), ServiceDestroyError>;
fn purge(&mut self) -> Result<(), InternalError>;
fn handle_message(
        &self,
        message_bytes: &[u8],
        message_context: &ServiceMessageContext
    ) -> Result<(), ServiceError>;
fn as_any(&self) -> &dyn Any; }

A Service provides message handling for a given service type.

Required methods

fn service_id(&self) -> &str[src]

This service’s ID

This ID must be unique within the context of a circuit, but not necessarily unique within the context of a splinter node, as a whole.

fn service_type(&self) -> &str[src]

This service’s type

A service type broadly identifies the kinds of messages that this service handles or emits.

fn start(
    &mut self,
    service_registry: &dyn ServiceNetworkRegistry
) -> Result<(), ServiceStartError>
[src]

Starts the service

At start time, the service should register itself with the network when its ready to receive messages.

fn stop(
    &mut self,
    service_registry: &dyn ServiceNetworkRegistry
) -> Result<(), ServiceStopError>
[src]

Stops Starts the service

The service should unregister itself with the network.

fn destroy(self: Box<Self>) -> Result<(), ServiceDestroyError>[src]

Clean-up any resources before the service is removed. Consumes the service (which, given the use of dyn traits, this must take a boxed Service instance).

fn purge(&mut self) -> Result<(), InternalError>[src]

Purge any persistent state maintained by this service.

fn handle_message(
    &self,
    message_bytes: &[u8],
    message_context: &ServiceMessageContext
) -> Result<(), ServiceError>
[src]

Handle any incoming message intended for this service instance.

Messages recevied by this service are provided in raw bytes. The format of the service

fn as_any(&self) -> &dyn Any[src]

Cast the service as &dyn Any.

This allows for downcasting the Service to a specific implementation.

Loading content...

Implementors

impl Service for AdminService[src]

fn service_id(&self) -> &str[src]

fn service_type(&self) -> &str[src]

fn start(
    &mut self,
    service_registry: &dyn ServiceNetworkRegistry
) -> Result<(), ServiceStartError>
[src]

fn stop(
    &mut self,
    service_registry: &dyn ServiceNetworkRegistry
) -> Result<(), ServiceStopError>
[src]

fn destroy(self: Box<Self>) -> Result<(), ServiceDestroyError>[src]

fn purge(&mut self) -> Result<(), InternalError>[src]

fn handle_message(
    &self,
    message_bytes: &[u8],
    message_context: &ServiceMessageContext
) -> Result<(), ServiceError>
[src]

fn as_any(&self) -> &dyn Any[src]

Loading content...