fn add_stream<S>(&mut self, fut: S) -> SpawnHandle
    where
        S: Stream + 'static,
        A: StreamHandler<S::Item>,
    {
        <A as StreamHandler<S::Item>>::add_stream(fut, self)
    }
/// Registers a stream with the context.
///
/// This allows handling a `Stream` in a way similar to normal
/// actor messages.
///
/// ```
/// # use std::io;
/// use actix::prelude::*;
/// use futures_util::stream::once;
///
/// #[derive(Message)]
/// #[rtype(result = "()")]
/// struct Ping;
///
/// struct MyActor;
///
/// impl StreamHandler<Ping> for MyActor {
///
///     fn handle(&mut self, item: Ping, ctx: &mut Context<MyActor>) {
///         println!("PING");
///         System::current().stop();
///     }
///
///     fn finished(&mut self, ctx: &mut Self::Context) {
///         println!("finished");
///     }
/// }
///
/// impl Actor for MyActor {
///    type Context = Context<Self>;
///
///    fn started(&mut self, ctx: &mut Context<Self>) {
///        // add stream
///        ctx.add_stream(once(async { Ping }));
///    }
/// }
///
/// fn main() {
///     let mut sys = System::new();
///     let addr = sys.block_on(async { MyActor.start() });
///     sys.run();
///  }
/// ```
Registers a stream with the context.
This allows handling a `Stream` in a way similar to normal
actor messages.


Registers a stream with the context . This allows handling a ` Stream ` in a way similar to normal actor messages .
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle
    where
        S: Stream + 'static,
        A: StreamHandler<S::Item>,
    {
        <A as StreamHandler<S::Item>>::add_stream(fut, self)
    }
fn add_stream < S > ( & mut self , fut : S ) -> SpawnHandle where S : Stream + ' static , A : StreamHandler < S :: Item > , { < A as StreamHandler < S :: Item > > :: add_stream ( fut , self ) }
Registers a stream with the context.
Registers a stream with the context .
&mut self
fut
S
&mut self
fut
S
use std::io;
use actix::prelude::*;
use futures_util::stream::once.
use actix :: prelude :: * ; use futures_util :: stream :: once .
[derive(message)]
None
[rtype(result = "()")]
struct Ping.

struct MyActor.

impl StreamHandler for MyActor {

fn handle(&mut self, item: Ping, ctx: &mut Context) {
println!("PING");
System::current().stop();
}

fn finished(&mut self, ctx: &mut Self::Context) {
println!("finished");
}
}

impl Actor for MyActor {
type Context = Context.

fn started(&mut self, ctx: &mut Context) {
add stream
ctx.add_stream(once(async { Ping }));
}
}

fn main() {
let mut sys = System::new();
let addr = sys.block_on(async { MyActor.start() });
sys.run();
}
```
struct Ping . struct MyActor . impl StreamHandler for MyActor { fn handle ( &mut self item : Ping ctx : &mut Context ) { println! ( " PING " ) ; System :: current () . stop () ; } fn finished ( &mut self ctx : &mut Self :: Context ) { println! ( " finished " ) ; } } impl Actor for MyActor { type Context = Context . fn started ( &mut self ctx : &mut Context ) { add stream ctx . add_stream ( once ( async { Ping } )) ; } } fn main () { let mut sys = System :: new () ; let addr = sys . block_on ( async { MyActor . start () } ) ; sys . run () ; } ` ` `