Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 17 fields pub api_id: i32, pub api_hash: String, pub dc_addr: Option<String>, pub retry_policy: Arc<dyn RetryPolicy>, pub socks5: Option<Socks5Config>, pub mtproxy: Option<MtProxyConfig>, pub allow_ipv6: bool, pub transport: TransportKind, pub session_backend: Arc<dyn SessionBackend>, pub catch_up: bool, pub restart_policy: Arc<dyn ConnectionRestartPolicy>, pub device_model: String, pub system_version: String, pub app_version: String, pub system_lang_code: String, pub lang_pack: String, pub lang_code: String,
}
Expand description

Configuration for Client::connect.

Fields§

§api_id: i32§api_hash: String§dc_addr: Option<String>§retry_policy: Arc<dyn RetryPolicy>§socks5: Option<Socks5Config>

Optional SOCKS5 proxy: every Telegram connection is tunnelled through it.

§mtproxy: Option<MtProxyConfig>

Optional MTProxy: if set, all TCP connections go to the proxy host:port instead of the Telegram DC address. The transport field is overridden by mtproxy.transport automatically.

§allow_ipv6: bool

Allow IPv6 DC addresses when populating the DC table (default: false).

§transport: TransportKind

Which MTProto transport framing to use (default: Abridged).

§session_backend: Arc<dyn SessionBackend>

Session persistence backend (default: binary file "ferogram.session").

§catch_up: bool

If true, replay missed updates via updates.getDifference immediately after connecting. Default: false.

§restart_policy: Arc<dyn ConnectionRestartPolicy>§device_model: String

Device model reported in InitConnection (default: "Linux").

§system_version: String

System/OS version reported in InitConnection (default: "1.0").

§app_version: String

App version reported in InitConnection (default: crate version).

§system_lang_code: String

System language code reported in InitConnection (default: "en").

§lang_pack: String

Language pack name reported in InitConnection (default: "").

§lang_code: String

Language code reported in InitConnection (default: "en").

Implementations§

Source§

impl Config

Source

pub fn with_string_session(s: impl Into<String>) -> Self

Convenience builder: use a portable base64 string session.

Pass the string exported from a previous client.export_session_string() call, or an empty string to start fresh (the string session will be populated after auth).

§Example
let cfg = Config {
api_id:   12345,
api_hash: "abc".into(),
catch_up: true,
..Config::with_string_session(std::env::var("SESSION").unwrap_or_default())
};

Set an MTProxy from a https://t.me/proxy?... or tg://proxy?... link.

Empty string is a no-op; proxy stays unset. Invalid link panics. Transport is selected from the secret prefix: plain hex = Obfuscated, dd prefix = PaddedIntermediate, ee prefix = FakeTLS.

§Example
use ferogram::Config;
const PROXY: &str = "https://t.me/proxy?server=HOST&port=443&secret=dd...";

let cfg = Config {
    api_id:   12345,
    api_hash: "abc".into(),
    ..Config::default().proxy_link(PROXY)
};
Source

pub fn proxy(self, host: impl Into<String>, port: u16, secret: &str) -> Self

Set an MTProxy from raw fields: host, port, and secret (hex or base64).

Secret decoding: 32+ hex chars are parsed as hex bytes, anything else as URL-safe base64. Transport is selected from the secret prefix, same as proxy_link.

§Example
use ferogram::Config;

let cfg = Config {
    api_id:   12345,
    api_hash: "abc".into(),
    // dd prefix = PaddedIntermediate, ee prefix = FakeTLS, plain = Obfuscated
    ..Config::default().proxy("proxy.example.com", 443, "ee0000000000000000000000000000000000706578616d706c652e636f6d")
};
Source

pub fn socks5(self, addr: impl Into<String>) -> Self

Set a SOCKS5 proxy (no authentication).

§Example
use ferogram::Config;

let cfg = Config {
    api_id:   12345,
    api_hash: "abc".into(),
    ..Config::default().socks5("127.0.0.1:1080")
};
Source

pub fn socks5_auth( self, addr: impl Into<String>, username: impl Into<String>, password: impl Into<String>, ) -> Self

Set a SOCKS5 proxy with username/password authentication.

§Example
use ferogram::Config;

let cfg = Config {
    api_id:   12345,
    api_hash: "abc".into(),
    ..Config::default().socks5_auth("proxy.example.com:1080", "user", "pass")
};

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate 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 Config

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more