Skip to main content

BearerOutcome

Enum BearerOutcome 

Source
#[non_exhaustive]
pub enum BearerOutcome { Anonymous, Validated(BearerIdentity), HeaderMissing, BearerEmpty, NoBrokerConfigured, Unknown, Expired, Revoked(String), BrokerNotConfigured, Lookup(String), Internal(String), }
Expand description

Outcome of a single bearer resolution.

The route handler in server.rs consumes this via Self::http_status / Self::www_authenticate / Self::retry_after / Self::rejection_message to build the response. Variants are deliberately fine-grained to match SP-token-broker-phase2 §4.4’s observable-distinction contract: adopters’ UIs (Celia’s “agent revoked” toast vs “code expired” prompt vs “you mistyped, try again”) need them.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Anonymous

No Authorization header present and require_bearer == false. Route handler proceeds with an empty CapabilitySet.

§

Validated(BearerIdentity)

Bearer header present and broker returned Ok(Some(identity)).

§

HeaderMissing

require_bearer == true and no Authorization header.

§

BearerEmpty

Authorization: Bearer present but token after the prefix is empty — pure client error (per spec §4.4 input contract).

§

NoBrokerConfigured

Header present and recognised as Bearer … but no broker is wired into HttpServerConfig.shared.token_broker. Adopter-side deployment misconfiguration (501 — server cannot honor the contract it claims).

§

Unknown

Broker returned Ok(None) — token is well-formed but unknown.

§

Expired

Broker returned Err(Expired).

§

Revoked(String)

Broker returned Err(Revoked(reason)).

§

BrokerNotConfigured

Broker returned Err(NotConfigured) — broker is wired but its resolve_bearer is the default-impl stub. Distinct from NoBrokerConfigured: the broker exists, it just won’t engage.

§

Lookup(String)

Broker returned Err(Lookup(reason)) — transient look-up failure (DB hiccup, network blip). Spec §4.4 says 503 + Retry-After: 5. The 2026-04 phase-1 doc had this conflated with “malformed bearer”; phase-2 clarifies it as transient.

§

Internal(String)

Broker returned Err(Internal(reason)) — broker bug. 500.

Implementations§

Source§

impl BearerOutcome

Source

pub fn http_status(&self) -> StatusCode

HTTP status code this outcome maps to. Validated / Anonymous return 200 as a sentinel — they should not be passed to the error response path.

Source

pub fn www_authenticate(&self) -> Option<&'static str>

Value for the WWW-Authenticate header, or None if no auth-challenge should be sent.

Source

pub fn retry_after(&self) -> Option<u64>

Value for the Retry-After header in seconds, or None. Per spec §4.4, only the transient Lookup outcome sends this.

Source

pub fn rejection_message(&self) -> Option<String>

Human-readable rejection message for the error response body. None for the success / continue outcomes.

Source

pub fn is_admitted(&self) -> bool

true if this outcome means “continue dispatch”; false if the response is an early-return error.

Trait Implementations§

Source§

impl Debug for BearerOutcome

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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