Trait irc::client::EachIncomingExt
[−]
[src]
pub trait EachIncomingExt: Stream<Item = Message, Error = IrcError> { 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 Client::stream
in order to use an API akin to
Client::for_each_incoming
.
Example
use irc::client::prelude::EachIncomingExt; client.stream().for_each_incoming(|irc_msg| { match irc_msg.command { Command::PRIVMSG(channel, message) => if message.contains(client.current_nickname()) { client.send_privmsg(&channel, "beep boop").unwrap(); } _ => () } }).unwrap();
Provided Methods
fn for_each_incoming<F>(self, f: F) -> Result<()> where
F: FnMut(Message),
Self: Sized,
F: FnMut(Message),
Self: Sized,
Blocks on the stream, running the given function on each incoming message as they arrive.