pub struct DcConnection { /* private fields */ }Implementations§
Source§impl DcConnection
impl DcConnection
Sourcepub async fn connect_fastest(
addr: &str,
socks5: Option<&Socks5Config>,
dc_id: i16,
) -> Result<(Self, String), InvocationError>
pub async fn connect_fastest( addr: &str, socks5: Option<&Socks5Config>, dc_id: i16, ) -> Result<(Self, String), InvocationError>
Races the default transport set (see default_transport_race).
Use connect_fastest_with to pass a custom race.
Sourcepub async fn connect_fastest_with(
addr: &str,
socks5: Option<&Socks5Config>,
dc_id: i16,
race: &[RaceLeg],
) -> Result<(Self, String), InvocationError>
pub async fn connect_fastest_with( addr: &str, socks5: Option<&Socks5Config>, dc_id: i16, race: &[RaceLeg], ) -> Result<(Self, String), InvocationError>
Races the given transports in parallel, each after its stagger delay, and returns whichever finishes DH first. Others are cancelled.
Sourcepub async fn connect_raw(
addr: &str,
socks5: Option<&Socks5Config>,
mtproxy: Option<&MtProxyConfig>,
transport: &TransportKind,
dc_id: i16,
) -> Result<Self, InvocationError>
pub async fn connect_raw( addr: &str, socks5: Option<&Socks5Config>, mtproxy: Option<&MtProxyConfig>, transport: &TransportKind, dc_id: i16, ) -> Result<Self, InvocationError>
Connect and perform full DH handshake, optionally via mtproxy.
Sourcepub async fn connect_with_key(
addr: &str,
auth_key: [u8; 256],
first_salt: i64,
time_offset: i32,
socks5: Option<&Socks5Config>,
mtproxy: Option<&MtProxyConfig>,
transport: &TransportKind,
dc_id: i16,
pfs: bool,
) -> Result<Self, InvocationError>
pub async fn connect_with_key( addr: &str, auth_key: [u8; 256], first_salt: i64, time_offset: i32, socks5: Option<&Socks5Config>, mtproxy: Option<&MtProxyConfig>, transport: &TransportKind, dc_id: i16, pfs: bool, ) -> Result<Self, InvocationError>
Connect with an already-known auth key (no DH needed).
If pfs is true, performs a temp-key DH bind before any RPCs.
Sourcepub fn auth_key_bytes(&self) -> [u8; 256]
pub fn auth_key_bytes(&self) -> [u8; 256]
The auth key this connection is currently encrypted with. Unlike
crate::MtpSender::auth_key_bytes, there’s no separate permanent
key tracked here, so under PFS this is the temporary key, not one
safe to persist to the session.
Sourcepub fn first_salt(&self) -> i64
pub fn first_salt(&self) -> i64
The server salt this connection started with.
Sourcepub fn time_offset(&self) -> i32
pub fn time_offset(&self) -> i32
Clock offset (seconds) between this client and the server.
Sourcepub fn into_parts(self) -> (TcpStream, FrameKind, EncryptedSession)
pub fn into_parts(self) -> (TcpStream, FrameKind, EncryptedSession)
Decompose this connection into its raw parts so it can be handed off
to crate::sender_task::spawn_sender_task, graduating it from a
single-request-at-a-time DcConnection into a pipelined background
sender task that supports multiple concurrent in-flight requests.
DcPool uses this once a connection has finished its setup (DH, PFS
bind, initConnection) as a plain DcConnection. ferogram’s transfer
workers (Client::open_worker_sender) use the same pattern to enable
request pipelining on upload/download connections.
Sourcepub async fn rpc_call<R: RemoteCall>(
&mut self,
req: &R,
) -> Result<Vec<u8>, InvocationError>
pub async fn rpc_call<R: RemoteCall>( &mut self, req: &R, ) -> Result<Vec<u8>, InvocationError>
Send req and block until its matching rpc_result comes back,
discarding or handling anything else that arrives in between (server
pushes, the periodic keepalive ping, salt/session-reset retries).
One request at a time; DcPool graduates connections that need
pipelined concurrent requests into a background sender task instead
of using this directly.
Sourcepub async fn rpc_call_serializable<S: Serializable>(
&mut self,
req: &S,
) -> Result<Vec<u8>, InvocationError>
pub async fn rpc_call_serializable<S: Serializable>( &mut self, req: &S, ) -> Result<Vec<u8>, InvocationError>
Like rpc_call but accepts any Serializable type (not just RemoteCall).
Sourcepub async fn rpc_call_raw(
&mut self,
body: &[u8],
) -> Result<Vec<u8>, InvocationError>
pub async fn rpc_call_raw( &mut self, body: &[u8], ) -> Result<Vec<u8>, InvocationError>
Send pre-serialized raw bytes and receive the raw response. Used by CDN download connections (no MTProto encryption layer).