Available on crate feature
model
only.Expand description
A helper class returned by ChannelId::messages_iter
Implementations
sourceimpl<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
sourceimpl<H: Clone + AsRef<Http>> Clone for MessagesIter<H>
impl<H: Clone + AsRef<Http>> Clone for MessagesIter<H>
sourcefn clone(&self) -> MessagesIter<H>
fn clone(&self) -> MessagesIter<H>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more