Skip to main content

Flows

Struct Flows 

Source
pub struct Flows { /* private fields */ }
Expand description

Every flow registered for one device.

The instance ID is shared — it identifies the device, not the flow — and each flow gets its own reg-id, numbered from the order flows were added. §4.2 requires that numbering to be stable across reboots, which is why it comes from position rather than from an allocator.

Implementations§

Source§

impl Flows

Source

pub fn for_instance(instance: InstanceId) -> Self

An empty set for a device.

The instance ID should be loaded from storage, not generated here on every start. §4.1 requires it to be persistent, and a UA that mints a fresh one each time accumulates dead bindings at the registrar and looks to it like a growing crowd of identical devices.

Source

pub fn instance(&self) -> &InstanceId

The device identity every flow in this set registers under.

Source

pub fn add( &mut self, endpoint: Handle, config: Config, target: Target, ) -> Result<RegId>

Add a flow to an outbound proxy, taking the next reg-id.

Returns the reg-id assigned, which the caller should persist alongside the proxy it belongs to: §4.2 wants the same number for the same flow after a restart.

Fails only if the set has grown past reg-id’s range, which would take 2^31 proxies.

Source

pub fn active(&self) -> usize

How many flows are currently registered.

Source

pub fn any_active(&self) -> bool

Whether any flow is up.

This is the question §4.5’s backoff turns on, and the reason a set is worth having: a UA with one working flow is reachable, and hurrying to re-establish the others only adds load to a registrar that is plainly having a bad day.

Source

pub fn active_flows(&self) -> Vec<RegId>

The flows that are up, by reg-id.

Source

pub async fn register(&mut self) -> Vec<Attempt>

Register every flow, and report what each one did.

One flow’s failure is not the set’s failure, which is the entire point. Every flow is attempted regardless of what the others did, and each result is returned separately — there is deliberately no Result wrapping the whole call for a caller to ? on.

Sequential rather than concurrent: the flows share a device and a set of credentials, and a registrar that is going to challenge will challenge all of them. Registering in parallel turns one nonce into a race, and §3.4.3’s nc counting is per nonce.

Source

pub async fn keepalive(&mut self) -> Vec<Attempt>

Keep every flow alive, and report which ones failed (RFC 5626 §4.4).

A flow whose keep-alive fails is marked down and given a §4.5 retry delay; the others are pinged and judged regardless. That is the criterion this whole module exists for: the point of registering to several outbound proxies is that one of them going away is survivable, and a keep-alive pass that stopped at the first failure would throw that away at exactly the moment it mattered.

Flows the registrar did not accept as Outbound are skipped: there is no flow, so there is nothing to keep alive, and pinging would be traffic nothing at the far end cares about.

Source

pub fn flow(&self, reg_id: RegId) -> Option<&UserAgent>

The agent for one flow, for a caller that needs to send through it.

Source

pub fn retry_after(&self, reg_id: RegId) -> Option<Duration>

How long to wait before retrying a flow that has failed, per RFC 5626 §4.5.

None for a flow that is up, or one this set does not have.

Trait Implementations§

Source§

impl Debug for Flows

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Flows

§

impl !RefUnwindSafe for Flows

§

impl Send for Flows

§

impl Sync for Flows

§

impl Unpin for Flows

§

impl UnsafeUnpin for Flows

§

impl !UnwindSafe for Flows

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.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,