Struct rust_tdlib::client::worker::Worker [−][src]
pub struct Worker<A, S> where
A: AuthStateHandler + Send + Sync + 'static,
S: TdLibClient + Send + Sync + Clone + 'static, { /* fields omitted */ }
Expand description
The main object in all interactions. You have to start worker and bind each client with worker using auth_client.
Implementations
pub async fn get_client_state(
&self,
client: &Client<T>
) -> RTDResult<(ClientState, AuthorizationState)>
pub async fn get_client_state(
&self,
client: &Client<T>
) -> RTDResult<(ClientState, AuthorizationState)>
Returns state of the client.
Drops authorized client. After method call you cannot interact with TDLib by the client.
pub async fn wait_auth_state_change(
&self,
client: &Client<T>
) -> RTDResult<RTDResult<ClientState, (RTDError, UpdateAuthorizationState)>>
pub async fn wait_auth_state_change(
&self,
client: &Client<T>
) -> RTDResult<RTDResult<ClientState, (RTDError, UpdateAuthorizationState)>>
Method waits for client state changes. If an error occured during authorization flow, you receive AuthorizationState on which it happened. You have to setup channel by call Client::builder().with_auth_state_channel(…)
Method waits for client state changes. It differ from wait_auth_state_change by error type: you won’t receive (AuthorizationState)[crate::types::authorization_state::AuthorizationState] when error occured. Method may be useful if client already authorized on, for example, previous application startup.
Binds client with worker and runs authorization routines. Method returns error if worker is not running or client already bound
Determines that the worker is running.
Starts interaction with TDLib. It returns JoinHandle which allows you to handle worker state: if it yields - so worker is definitely stopped.
Stops the client.
You may want to await JoinHandle retrieved with client.start().await
after calling stop
.
pub async fn handle_auth_state(
&self,
auth_state: &AuthorizationState,
client: &Client<T>
) -> RTDResult<()>
Trait Implementations
Auto Trait Implementations
impl<A, S> !RefUnwindSafe for Worker<A, S>
impl<A, S> !UnwindSafe for Worker<A, S>
Blanket Implementations
Mutably borrows from an owned value. Read more