Trait irc::client::server::EachIncomingExt [] [src]

pub trait EachIncomingExt: Stream<Item = Message, Error = Error> {
    fn for_each_incoming<F>(self, f: F) -> Result<()>
    where
        F: FnMut(Message),
        Self: Sized
, { ... } }

Trait extending all IRC streams with for_each_incoming convenience function.

This is typically used in conjunction with Server::stream in order to use an API akin to Server::for_each_incoming.

Example

use irc::client::prelude::EachIncomingExt;

server.stream().for_each_incoming(|irc_msg| {
  match irc_msg.command {
    Command::PRIVMSG(channel, message) => if message.contains(server.current_nickname()) {
      server.send_privmsg(&channel, "beep boop").unwrap();
    }
    _ => ()
  }
}).unwrap();

Provided Methods

Blocks on the stream, running the given function on each incoming message as they arrive.

Implementors