Skip to main content

run_blocking

Function run_blocking 

Source
pub fn run_blocking(options: &Options) -> Result<RunOutcome, AuthError>
Expand description

Executes authentication synchronously using a temporary Tokio runtime.

This helper works without the cli feature or any runtime setup by the caller. Each call creates a current-thread runtime with I/O and timers enabled, runs run, and drops the runtime before returning. It does not initialize logging or print the outcome.

Call this from synchronous code. Within an async Tokio context, use run directly. Threads entered into a Tokio runtime, including spawn_blocking threads, are rejected.

§Errors

Returns AuthError::Config when called within an active Tokio runtime, AuthError::Io if runtime creation fails, or any error returned by run.

§Example

use node_auth::{run_blocking, Options};

fn main() -> Result<(), node_auth::AuthError> {
    let outcome = run_blocking(&Options::default())?;
    // Handle the returned token or updated configuration paths.
    Ok(())
}