rho-coding-agent 3.12.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use rho_providers::credentials::{CredentialError, CredentialResult};

/// Runs a credential read on tokio's blocking pool, so a slow store never
/// stalls an async worker. The read is bounded by its backend, not here: the
/// Secret Service reader never unlocks and has its own deadline, while a macOS
/// keychain access prompt is for the user to answer, however long that takes.
pub(crate) async fn read_off_workers<T: Send + 'static>(
    operation: impl FnOnce() -> T + Send + 'static,
) -> CredentialResult<T> {
    match tokio::task::spawn_blocking(operation).await {
        Ok(value) => Ok(value),
        Err(error) if error.is_panic() => std::panic::resume_unwind(error.into_panic()),
        Err(error) => Err(CredentialError::StoreUnavailable(format!(
            "the runtime shut down before the credential read finished: {error}"
        ))),
    }
}