Skip to main content

ErasedAuthPort

Trait ErasedAuthPort 

Source
pub trait ErasedAuthPort: Send + Sync {
    // Required method
    fn erased_resolve_token<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<String, AuthError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Object-safe version of AuthPort for runtime dispatch.

AuthPort uses native async fn in trait (Rust 2024) and is NOT object-safe. ErasedAuthPort wraps the same logic via async_trait, producing Pin<Box<dyn Future>> return types that Arc<dyn ...> requires.

A blanket impl<T: AuthPort> ErasedAuthPort for T is provided — you never need to implement this trait directly.

§Example

use std::sync::Arc;
use stygian_graph::ports::auth::{ErasedAuthPort, EnvAuthPort};

let port: Arc<dyn ErasedAuthPort> = Arc::new(EnvAuthPort::new("GITHUB_TOKEN"));
// Pass `port` to GraphQlService::with_auth_port(port)

Required Methods§

Source

fn erased_resolve_token<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Resolve a live access-token string — load, check expiry, refresh if needed.

§Errors

Returns Err if no token exists, storage is unavailable, or refresh fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§