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, &'static str), InvocationError>
pub async fn connect_fastest( addr: &str, socks5: Option<&Socks5Config>, dc_id: i16, ) -> Result<(Self, &'static str), InvocationError>
Race Obfuscated / Abridged / Http transports and return the first to succeed.
Sourcepub async fn connect_raw(
addr: &str,
socks5: Option<&Socks5Config>,
transport: &TransportKind,
dc_id: i16,
) -> Result<Self, InvocationError>
pub async fn connect_raw( addr: &str, socks5: Option<&Socks5Config>, transport: &TransportKind, dc_id: i16, ) -> Result<Self, InvocationError>
Connect and perform full DH handshake.
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 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).
Auto Trait Implementations§
impl !Freeze for DcConnection
impl !RefUnwindSafe for DcConnection
impl !UnwindSafe for DcConnection
impl Send for DcConnection
impl Sync for DcConnection
impl Unpin for DcConnection
impl UnsafeUnpin for DcConnection
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> 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