serviceless 0.6.1

An simple actor model in rust, like actix
Documentation
use crate::{Context, Envelope, Metadata, RuntimedService};
use futures_core::Stream;

use async_trait::async_trait;

#[async_trait]
pub trait Service: Send + Sized + 'static {
    type Stream: Stream<Item = Envelope<Self>> + Unpin + Send;

    fn metadata(&self) -> Metadata<'_>;

    /// Hook for service started
    async fn started(&mut self, _ctx: &mut Context<Self>) {}

    /// Hook for service stopped
    async fn stopped(&mut self, _ctx: &mut Context<Self>) {}
}

#[async_trait]
impl<T> RuntimedService for T
where
    T: Service,
{
    type Stream = T::Stream;

    type Runtime = crate::runtime_impl::tokio::TokioRuntime;

    fn metadata(&self) -> Metadata<'_> {
        self.metadata()
    }

    async fn started(&mut self, _ctx: &mut Context<Self>) {
        self.started(_ctx).await
    }

    async fn stopped(&mut self, _ctx: &mut Context<Self>) {
        self.stopped(_ctx).await
    }
}