Struct grammers_client::client::client::InitParams

source ·
pub struct InitParams {
    pub device_model: String,
    pub system_version: String,
    pub app_version: String,
    pub system_lang_code: String,
    pub lang_code: String,
    pub catch_up: bool,
    pub server_addr: Option<SocketAddr>,
    pub flood_sleep_threshold: u32,
    pub update_queue_limit: Option<usize>,
    pub reconnection_policy: &'static dyn ReconnectionPolicy,
}
Expand description

Optional initialization parameters, required when initializing a connection to Telegram’s API.

Fields§

§device_model: String§system_version: String§app_version: String§system_lang_code: String§lang_code: String§catch_up: bool

Should the client catch-up on updates sent to it while it was offline?

By default, updates sent while the client was offline are ignored.

§server_addr: Option<SocketAddr>

Server address to connect to. By default, the library will connect to the address stored in the session file (or a default production address if no such address exists). This field can be used to override said address, and is most commonly used to connect to one of Telegram’s test servers instead.

§flood_sleep_threshold: u32

The threshold below which the library should automatically sleep on flood-wait and slow mode wait errors (inclusive). For instance, if an RpcError { name: "FLOOD_WAIT", value: Some(17) } (flood, must wait 17 seconds) occurs and flood_sleep_threshold is 20 (seconds), the library will sleep automatically for 17 seconds. If the error was for 21s, it would propagate the error instead.

By default, the library will sleep on flood-waits below or equal to one minute (60 seconds), but this can be disabled by passing 0 (since all flood errors would be higher and exceed the threshold).

On flood, the library will retry once. If the flood error occurs a second time after sleeping, the error will be returned.

§update_queue_limit: Option<usize>

How many updates may be buffered by the client at any given time.

Telegram passively sends updates to the client through the open connection, so they must be buffered until the application has the capacity to consume them.

Upon reaching this limit, updates will be dropped, and a warning log message will be emitted (but not too often, to avoid spamming the log), in order to let the developer know that they should either change how they handle updates or increase the limit.

A limit of zero (0) indicates that updates should not be buffered. They will be immediately dropped, and no warning will ever be emitted.

A limit of None disables the upper bound for the buffer. This is not recommended, as it could eventually lead to memory exhaustion. This option will also not emit any warnings.

The default limit, which may change at any time, should be enough for user accounts, although bot accounts may need to increase the limit depending on their capacity.

When the limit is Some, a buffer to hold that many updates will be pre-allocated.

§reconnection_policy: &'static dyn ReconnectionPolicy

specify the reconnection policy which will be used by client to determine whether to re-connect on failure or not.

it can be one of the 2 default implementation NoReconnect and FixedReconnect;

OR your own custom implementation of trait ReconnectionPolicy.

for more details refer to examples

Trait Implementations§

source§

impl Clone for InitParams

source§

fn clone(&self) -> InitParams

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for InitParams

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.