pub struct ServiceContext<S: Service> { /* private fields */ }
Expand description

Backing context for a service which handles storing the reciever for messaging and the original link for spawning copies

Implementations§

source§

impl<S: Service> ServiceContext<S>

source

pub fn attach_sink<Si, I>(&self, sink: Si) -> SinkLink<I>where S: ErrorHandler<Si::Error>, Si: Sink<I> + Send + Unpin + 'static, Si::Error: Send + 'static, I: Send + 'static,

Attaches a sink to this service and provides a link to the service so that it can be used to write messages

sink The sink to attach

source§

impl<S> ServiceContext<S>where S: Service,

source

pub fn attach_stream<St>(&self, stream: St, stop: bool)where S: StreamHandler<St::Item>, St: Stream + Send + Unpin + 'static, St::Item: Send + 'static,

Attaches a streaming reciever to the service context

implement the StreamHandler trait on your service with the item as the Item type of the provided stream in order to handle accepting items from the stream

stream The stream to accept from stop Whether to stop the main service when this stream service ends

source§

impl<S> ServiceContext<S>where S: Service,

source

pub fn stop(&mut self)

Stop the context directly by closing the reciever the reciever will drain any existing messages until there are none remaining

Creates and returns a link to the service

Returns a reference to the shared link used by this context for creating new links. You can use this to access the service link without creating a clone of it

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for ServiceContext<S>

§

impl<S> Send for ServiceContext<S>

§

impl<S> Sync for ServiceContext<S>

§

impl<S> Unpin for ServiceContext<S>

§

impl<S> !UnwindSafe for ServiceContext<S>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.