Trait crossbus::stream::Stream

source ·
pub trait Stream<Item>where
    Self: Actor,{
    // Required method
    fn action(&mut self, msg: Item, ctx: &mut Context<Self>);

    // Provided methods
    fn started(&mut self, _: &mut Context<Self>) { ... }
    fn state(&mut self, _: &mut Context<Self>) -> StreamingState { ... }
    fn spawn_stream<S>(&mut self, ctx: &mut Context<Self>, stream: S) -> Handle
       where S: Stream + 'static,
             Self: Stream<S::Item> { ... }
    fn aborted(&mut self, _: &mut Context<Self>) { ... }
    fn paused(&mut self, _: &mut Context<Self>) { ... }
    fn resumed(&mut self, _: &mut Context<Self>) { ... }
    fn finished(&mut self, _: &mut Context<Self>) { ... }
}
Expand description

An abstraction for Actor’s stream routine

Required Methods§

source

fn action(&mut self, msg: Item, ctx: &mut Context<Self>)

action to do for the Stream Item

Provided Methods§

source

fn started(&mut self, _: &mut Context<Self>)

called before the actor emit the first Strem Item

source

fn state(&mut self, _: &mut Context<Self>) -> StreamingState

change the state of stream to abort/pause/resume the stream accordingly

Real-Time control or more elaborated execution could be achieved right here

source

fn spawn_stream<S>(&mut self, ctx: &mut Context<Self>, stream: S) -> Handlewhere S: Stream + 'static, Self: Stream<S::Item>,

spawn stream to the actor

source

fn aborted(&mut self, _: &mut Context<Self>)

called after the actor aborts the stream

source

fn paused(&mut self, _: &mut Context<Self>)

called after the actor pause the stream

source

fn resumed(&mut self, _: &mut Context<Self>)

called after the actor resume the stream

source

fn finished(&mut self, _: &mut Context<Self>)

called after the actor send the last Strem Item

Implementors§