Skip to main content

HeaderSource

Struct HeaderSource 

Source
pub struct HeaderSource(/* private fields */);
Expand description

Where a Rust host transport reads its request headers (auth, actor and project ids, per-round trace headers). The transport calls it before every host-authenticated HTTP request and every realtime handshake; a signed URL never carries them. It receives the request’s HeaderContext and None for an ordinary read, or the headers the server just answered 401 to for a refresh. A source that answers None has no headers to give, and the request fails with the retryable sync.auth_required (causeKind: "header_source") before any network I/O.

Concurrent reads of one client and round share one in-flight call, with the first reader’s context. Ordinary reads and refreshes fly separately, so a refresh never joins an ordinary read of the refused headers, and different rounds or clients never share a call. Clones share the flights.

Implementations§

Source§

impl HeaderSource

Source

pub fn new( read: impl Fn(&HeaderContext, Option<&[(String, String)]>) -> Option<Vec<(String, String)>> + Send + Sync + 'static, ) -> Self

Source

pub fn read( &self, context: &HeaderContext, rejected: Option<&[(String, String)]>, ) -> Result<Vec<(String, String)>, TransportError>

Read the headers for one request, joining the flight of the same client, round and kind when one is in progress.

Source

pub fn authenticated<T>( &self, context: &HeaderContext, send: impl FnMut(&[(String, String)]) -> Result<T, TransportError>, ) -> Result<T, TransportError>

Run one host-authenticated request with this source’s headers. A refusal carrying details.httpStatus 401 reads the source again, in the same context, with the refused headers and resends once; a second 401 surfaces.

Trait Implementations§

Source§

impl Clone for HeaderSource

Source§

fn clone(&self) -> Self

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 Debug for HeaderSource

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

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.