pub struct LoginDriver { /* private fields */ }Expand description
A phone login as a state machine, for a daemon: start
sends ONE challenge (after the injected SendBudget allows it), then
submit_code or poll until the
state is terminal, or cancel. Writes no files and logs
nothing. The isolated browser context is disposed when the login ends;
call cancel when abandoning a driver so it is disposed promptly (an
abandoned one is otherwise only cleaned up by the browser).
Implementations§
Source§impl LoginDriver
impl LoginDriver
Sourcepub async fn start(req: LoginRequest<'_>, budget: &dyn SendBudget) -> Self
pub async fn start(req: LoginRequest<'_>, budget: &dyn SendBudget) -> Self
Open the login page in a fresh isolated context and send one
challenge. Never fails: errors become LoginState::Failed.
pub fn state(&self) -> &LoginState
Sourcepub fn pending(&self) -> Option<&PendingLogin>
pub fn pending(&self) -> Option<&PendingLogin>
The pending login (no secrets), e.g. to show its expiry.
Sourcepub async fn submit_code(&mut self, code: &str) -> &LoginState
pub async fn submit_code(&mut self, code: &str) -> &LoginState
Type code into the page. Only valid while awaiting a code.
Sourcepub async fn poll(&mut self, wait: Duration) -> &LoginState
pub async fn poll(&mut self, wait: Duration) -> &LoginState
Wait up to wait for the in-app approval (keep it short and call
again; e.g. 5 s). Only valid while awaiting approval.
Sourcepub async fn cancel(&mut self) -> &LoginState
pub async fn cancel(&mut self) -> &LoginState
Dispose the isolated context and end the login (the send still counts against the budget).
Sourcepub fn into_session(self) -> Option<Session>
pub fn into_session(self) -> Option<Session>
The session once LoginState::Done.