Skip to main content

ResolverEnvironment

Struct ResolverEnvironment 

Source
pub struct ResolverEnvironment {
    pub env_lookup: Arc<dyn Fn(&str) -> Option<String> + Sync + Send>,
    pub external_resolvers: BTreeMap<String, Arc<dyn ExternalAuthResolverHandle>>,
    pub now: Arc<dyn Fn() -> DateTime<Utc> + Sync + Send>,
    pub force_refresh: bool,
    pub auth_lease_handle: Option<Arc<dyn AuthLeaseHandle>>,
    pub token_store: Option<Arc<dyn TokenStore>>,
    pub refresh_coord: Option<Arc<dyn RefreshCoordinator>>,
}
Expand description

Explicit environment passed to provider resolvers.

env_lookup replaces direct std::env::var calls — the resolution stack reads env only through this closure. Tests seed a closure that returns programmed values; production wiring uses ResolverEnvironment::with_process_env.

token_store + refresh_coord are consulted by OAuth-backed auth methods (Claude.ai, ChatGPT, Google OAuth-personal) to find a persisted access/refresh token. Absent store → OAuth paths return AuthError::InteractiveLoginRequired.

Fields§

§env_lookup: Arc<dyn Fn(&str) -> Option<String> + Sync + Send>§external_resolvers: BTreeMap<String, Arc<dyn ExternalAuthResolverHandle>>§now: Arc<dyn Fn() -> DateTime<Utc> + Sync + Send>§force_refresh: bool§auth_lease_handle: Option<Arc<dyn AuthLeaseHandle>>§token_store: Option<Arc<dyn TokenStore>>§refresh_coord: Option<Arc<dyn RefreshCoordinator>>

Implementations§

Source§

impl ResolverEnvironment

Source

pub fn testing() -> ResolverEnvironment

Testing default — env lookup always returns None, no external resolvers, now returns the current UTC time.

Source

pub fn with_process_env() -> ResolverEnvironment

Wraps std::env::var in a closure so the new stack never reads env directly.

Source

pub fn with_token_store(self, store: Arc<dyn TokenStore>) -> ResolverEnvironment

Attach a token store for OAuth-backed auth methods.

Source

pub fn with_refresh_coordinator( self, coord: Arc<dyn RefreshCoordinator>, ) -> ResolverEnvironment

Attach a refresh coordinator. If with_token_store is set but no coordinator is, callers fall back to InMemoryCoordinator::new().

Source

pub fn with_external_resolver( self, handle: impl Into<String>, resolver: Arc<dyn ExternalAuthResolverHandle>, ) -> ResolverEnvironment

Register an external auth resolver under a handle name.

Source

pub fn with_auth_lease_handle( self, handle: Arc<dyn AuthLeaseHandle>, ) -> ResolverEnvironment

Attach the session-owned auth lease handle so dynamic cloud authorizers can publish observed token freshness into AuthMachine truth after a lazy token exchange.

Source

pub fn with_force_refresh(self, force_refresh: bool) -> ResolverEnvironment

Force provider runtimes to take their refresh path even when persisted credentials are still fresh.

Source

pub fn with_env_lookup<F>(self, lookup: F) -> ResolverEnvironment
where F: Fn(&str) -> Option<String> + Send + Sync + 'static,

Seed a custom env lookup closure (for tests).

Trait Implementations§

Source§

impl Clone for ResolverEnvironment

Source§

fn clone(&self) -> ResolverEnvironment

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ResolverEnvironment

Source§

fn default() -> ResolverEnvironment

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more