pub struct MessagesIter<H: AsRef<Http>> { /* private fields */ }
Expand description
A helper class returned by ChannelId::messages_iter
Implementations§
Source§impl<H: AsRef<Http>> MessagesIter<H>
impl<H: AsRef<Http>> MessagesIter<H>
Sourcepub fn stream(
http: impl AsRef<Http>,
channel_id: ChannelId,
) -> impl Stream<Item = Result<Message>>
pub fn stream( http: impl AsRef<Http>, channel_id: ChannelId, ) -> impl Stream<Item = Result<Message>>
Streams over all the messages in a channel.
This is accomplished and equivalent to repeated calls to ChannelId::messages
. A buffer
of at most 100 messages is used to reduce the number of calls necessary.
The stream returns the newest message first, followed by older messages.
§Examples
use serenity::futures::StreamExt;
use serenity::model::channel::MessagesIter;
let mut messages = MessagesIter::<Http>::stream(&ctx, channel_id).boxed();
while let Some(message_result) = messages.next().await {
match message_result {
Ok(message) => println!("{} said \"{}\"", message.author.name, message.content,),
Err(error) => eprintln!("Uh oh! Error: {}", error),
}
}
Trait Implementations§
Auto Trait Implementations§
impl<H> Freeze for MessagesIter<H>where
H: Freeze,
impl<H> RefUnwindSafe for MessagesIter<H>where
H: RefUnwindSafe,
impl<H> Send for MessagesIter<H>where
H: Send,
impl<H> Sync for MessagesIter<H>where
H: Sync,
impl<H> Unpin for MessagesIter<H>where
H: Unpin,
impl<H> UnwindSafe for MessagesIter<H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more