[][src]Struct sonr::net::tcp::ReactiveTcpListener

pub struct ReactiveTcpListener { /* fields omitted */ }

Accept incoming connections and output (TcpStream, SocketAddr);

 use sonr::net::tcp::{ReactiveTcpListener, TcpStream};

 fn main() -> Result<()> {
     let system_signals = System::init()?;
     let listener = ReactiveTcpListener::bind("")?;
     let run = listener.map(|(strm, addr)| {
         eprintln!("connection from: {:?}", addr);


impl ReactiveTcpListener[src]

pub fn new(listener: TcpListener) -> Result<Self>[src]

Create a new listener from a mio::TcpListener

pub fn bind(addr: &str) -> Result<Self>[src]

Create a new listener from an address

pub fn token(&self) -> Token[src]

Get Token registered with the listener;

Trait Implementations

impl Reactor for ReactiveTcpListener[src]

type Output = (TcpStream, SocketAddr)

The output passed to the next reactor in the chain.

type Input = ()

Expected input type from the previous reactor in the chain.

fn chain<T: Reactor>(self, to: T) -> Chain<Self, T>[src]

Chain two reactors together. The output of the first reactor is the input of the second reactor. Read more

fn and<C: Reactor>(self, second: C) -> And<Self, C>[src]

Run two reactors independent of each other. ```no_run # use sonr::reactor::Reactor; # use sonr::errors::Result; use sonr::system::System; use sonr::net::tcp::ReactiveTcpListener; Read more

fn map<F, T>(self, callback: F) -> Map<Self, F, T>[src]

Capture the output of a reactor in a closure. no_run // Create a listener, print the address every time // the listener accepts a new connection, then push that // connection onto a queue. # use sonr::net::tcp; # use sonr::sync::queue::ReactiveQueue; # use sonr::errors::Result; # use sonr::prelude::*; # fn main() -> Result<()> { System::init(); let listener = tcp::ReactiveTcpListener::bind("")?; let queue = ReactiveQueue::unbounded(); let server = listener.map(|(stream, addr)| { stream }).chain(queue); System::start(server); # Ok(()) # } Read more

fn or<T: Reactor>(self, second: T) -> Or<Self, T>[src]

Pass the output from a reactor into one of two reactors depending on the output. Note that both Reactors in an or are required to have the same output, and it's only possible to chain two ored reactors if the reactor that does the chaining outputs Either. Read more

Auto Trait Implementations

impl !Send for ReactiveTcpListener

impl !Sync for ReactiveTcpListener

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized

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

impl<T> BorrowMut for T where
    T: ?Sized

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

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

The type returned in the event of a conversion error.

impl<T> Erased for T