Struct IterBuffer

Source
pub struct IterBuffer<R, T> { /* private fields */ }
Expand description

Common parts to all requests that are used for creating iterators.

End-users should obtain particular instances of this type via client methods.

Implementations§

Source§

impl IterBuffer<GetInlineBotResults, InlineResult>

Source

pub fn chat<C: Into<PackedChat>>(self, chat: C) -> Self

Indicate the bot the chat where this inline query will be sent to.

Some bots use this information to return different results depending on the type of the chat, and some even “need” it to give useful results.

Source

pub async fn next(&mut self) -> Result<Option<InlineResult>, InvocationError>

Return the next InlineResult from the internal buffer, filling the buffer previously if it’s empty.

Returns None if the limit is reached or there are no results left.

Source§

impl IterBuffer<GetDialogs, Dialog>

Source

pub async fn total(&mut self) -> Result<usize, InvocationError>

Determines how many dialogs there are in total.

This only performs a network call if next has not been called before.

Source

pub async fn next(&mut self) -> Result<Option<Dialog>, InvocationError>

Return the next Dialog from the internal buffer, filling the buffer previously if it’s empty.

Returns None if the limit is reached or there are no dialogs left.

Source§

impl IterBuffer<GetHistory, Message>

Source

pub fn offset_id(self, offset: i32) -> Self

Source

pub fn max_date(self, offset: i32) -> Self

Source

pub async fn total(&mut self) -> Result<usize, InvocationError>

Determines how many messages there are in total.

This only performs a network call if next has not been called before.

Source

pub async fn next(&mut self) -> Result<Option<Message>, InvocationError>

Return the next Message from the internal buffer, filling the buffer previously if it’s empty.

Returns None if the limit is reached or there are no messages left.

Source§

impl IterBuffer<Search, Message>

Source

pub fn offset_id(self, offset: i32) -> Self

Source

pub fn query(self, query: &str) -> Self

Changes the query of the search. Telegram servers perform a somewhat fuzzy search over this query (so a word in singular may also return messages with the word in plural, for example).

Source

pub fn sent_by_self(self) -> Self

Restricts results to messages sent by the logged-in user

Source

pub fn min_date(self, date_time: &DateTime<FixedOffset>) -> Self

Returns only messages with date bigger than date_time.

use chrono::DateTime;

// Search messages sent after Jan 1st, 2021
let min_date = DateTime::parse_from_rfc3339("2021-01-01T00:00:00-00:00").unwrap();

let mut messages = client.search_messages(&chat).min_date(&min_date);
Source

pub fn max_date(self, date_time: &DateTime<FixedOffset>) -> Self

Returns only messages with date smaller than date_time

use chrono::DateTime;

// Search messages sent before Dec, 25th 2022
let max_date = DateTime::parse_from_rfc3339("2022-12-25T00:00:00-00:00").unwrap();

let mut messages = client.search_messages(&chat).max_date(&max_date);
Source

pub fn filter(self, filter: MessagesFilter) -> Self

Changes the media filter. Only messages with this type of media will be fetched.

Source

pub async fn total(&mut self) -> Result<usize, InvocationError>

Determines how many messages there are in total.

This only performs a network call if next has not been called before.

Source

pub async fn next(&mut self) -> Result<Option<Message>, InvocationError>

Return the next Message from the internal buffer, filling the buffer previously if it’s empty.

Returns None if the limit is reached or there are no messages left.

Source§

impl IterBuffer<SearchGlobal, Message>

Source

pub fn offset_id(self, offset: i32) -> Self

Source

pub fn query(self, query: &str) -> Self

Changes the query of the search. Telegram servers perform a somewhat fuzzy search over this query (so a word in singular may also return messages with the word in plural, for example).

Source

pub fn filter(self, filter: MessagesFilter) -> Self

Changes the media filter. Only messages with this type of media will be fetched.

Source

pub async fn total(&mut self) -> Result<usize, InvocationError>

Determines how many messages there are in total.

This only performs a network call if next has not been called before.

Source

pub async fn next(&mut self) -> Result<Option<Message>, InvocationError>

Return the next Message from the internal buffer, filling the buffer previously if it’s empty.

Returns None if the limit is reached or there are no messages left.

Source§

impl<R, T> IterBuffer<R, T>

Source

pub fn limit(self, n: usize) -> Self

Change how many items will be returned from the iterator.

Using limit instead of take on the iterator is useful because outgoing requests can ask for less items from the server to only fetch what’s needed.

Auto Trait Implementations§

§

impl<R, T> Freeze for IterBuffer<R, T>
where R: Freeze,

§

impl<R, T> !RefUnwindSafe for IterBuffer<R, T>

§

impl<R, T> Send for IterBuffer<R, T>
where R: Send, T: Send,

§

impl<R, T> Sync for IterBuffer<R, T>
where R: Sync, T: Sync,

§

impl<R, T> Unpin for IterBuffer<R, T>
where R: Unpin, T: Unpin,

§

impl<R, T> !UnwindSafe for IterBuffer<R, T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.