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: boolAllow IPv6 DC addresses when populating the DC table (default: false).
transport: TransportKindWhich MTProto transport framing to use (default: Abridged).
session_backend: Arc<dyn SessionBackend>Session persistence backend (default: binary file "ferogram.session").
catch_up: boolIf true, replay missed updates via updates.getDifference immediately
after connecting.
Default: false.
restart_policy: Arc<dyn ConnectionRestartPolicy>§device_model: StringDevice model reported in InitConnection (default: "Linux").
system_version: StringSystem/OS version reported in InitConnection (default: "1.0").
app_version: StringApp version reported in InitConnection (default: crate version).
system_lang_code: StringSystem language code reported in InitConnection (default: "en").
lang_pack: StringLanguage pack name reported in InitConnection (default: "").
lang_code: StringLanguage code reported in InitConnection (default: "en").
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_string_session(s: impl Into<String>) -> Self
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())
};Sourcepub fn proxy_link(self, url: &str) -> Self
pub fn proxy_link(self, url: &str) -> Self
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)
};Sourcepub fn proxy(self, host: impl Into<String>, port: u16, secret: &str) -> Self
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")
};Sourcepub fn socks5(self, addr: impl Into<String>) -> Self
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")
};Sourcepub fn socks5_auth(
self,
addr: impl Into<String>,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
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§
Auto Trait Implementations§
impl Freeze for Config
impl !RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl !UnwindSafe for Config
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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