Skip to main content

Tracker

Struct Tracker 

Source
pub struct Tracker<Con, Context = (), State = ()>
where Con: Consumer, Con::Value: Clone + Send + 'static, Context: Clone + Send + 'static,
{ /* private fields */ }
Expand description

Tracks in-flight consumer deliveries keyed by resolver key.

Context carries resolver-specific metadata back to the caller when validation completes.

State holds per-key resolver state that should be dropped when the key is pruned, or explicitly taken when the resolver completes the fetch.

Implementations§

Source§

impl<Con, Context, State> Tracker<Con, Context, State>
where Con: Consumer, Con::Value: Clone + Send + 'static, Context: Clone + Send + 'static,

Source

pub fn new(consumer: Con) -> Self

Create an empty tracker backed by the provided consumer.

Source

pub fn contains(&self, key: &Con::Key) -> bool

Returns true when the key has an active tracked fetch.

Source

pub fn remove(&mut self, key: &Con::Key) -> bool

Remove a key and abort any in-progress delivery for it.

Returns true if the key was present. Any completion produced by an aborted delivery is discarded by next_completion.

Source

pub fn retain<F: FnMut(&Con::Key) -> bool>(&mut self, predicate: F) -> usize

Retain only entries for which the predicate returns true.

Dropped entries abort in-progress deliveries. Returns the number of removed entries.

Source

pub fn drain(&mut self) -> usize

Remove all entries and abort all in-progress deliveries.

Returns the number of entries removed.

Source

pub fn deliver( &mut self, delivery: Delivery<Con::Key, Con::Subscriber>, context: Context, value: Con::Value, )

Deliver a newly received response to the consumer.

The response is cached so that, after the consumer accepts it, later retained subscribers can be redelivered the same bytes with redeliver. Panics if the key is not tracked.

Source

pub fn redeliver(&mut self, delivery: Delivery<Con::Key, Con::Subscriber>)

Deliver the cached response to another set of subscribers.

This is intended for subscribers added while the first validation was still pending. Panics if the key is not tracked, no response is cached, or the cached response has not yet been accepted.

Source

pub fn response_accepted(&self, key: &Con::Key) -> bool

Returns true if the cached response for this key has been accepted.

Source

pub fn accept_response(&mut self, key: &Con::Key)

Mark the cached response accepted by the consumer.

Panics if the key is not tracked or no response is cached.

Source

pub fn discard_response(&mut self, key: &Con::Key)

Drop the cached response without removing the tracked key.

Use this after a consumer rejects a response and the resolver wants to retry the same key with different bytes or metadata.

Source

pub async fn next_completion( &mut self, ) -> Result<Completion<Con::Key, Con::Subscriber, Context>, Aborted>

Wait for the next consumer validation result.

Returns Aborted when the delivery was canceled before completion. Successful completions clear the active delivery slot for that key so it can be retried or redelivered. Completions for an older same-key delivery are treated as aborted.

Source§

impl<Con, Context> Tracker<Con, Context>
where Con: Consumer, Con::Value: Clone + Send + 'static, Context: Clone + Send + 'static,

Source

pub fn insert(&mut self, key: Con::Key) -> bool

Start tracking a key without any resolver-specific state.

Returns true when the key was inserted. If the key is already tracked, this leaves the existing entry untouched and returns false.

Auto Trait Implementations§

§

impl<Con, Context = (), State = ()> !Freeze for Tracker<Con, Context, State>

§

impl<Con, Context = (), State = ()> !RefUnwindSafe for Tracker<Con, Context, State>

§

impl<Con, Context, State> Send for Tracker<Con, Context, State>
where <Con as Consumer>::Value: Sized, State: Send,

§

impl<Con, Context = (), State = ()> !Sync for Tracker<Con, Context, State>

§

impl<Con, Context, State> Unpin for Tracker<Con, Context, State>
where <Con as Consumer>::Value: Sized + Unpin, Con: Unpin, <Con as Consumer>::Key: Unpin, State: Unpin, Context: Unpin,

§

impl<Con, Context, State> UnsafeUnpin for Tracker<Con, Context, State>
where <Con as Consumer>::Value: Sized, Con: UnsafeUnpin,

§

impl<Con, Context = (), State = ()> !UnwindSafe for Tracker<Con, Context, State>

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

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> 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 = 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<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
Source§

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