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
impl Flows
Sourcepub fn for_instance(instance: InstanceId) -> Self
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.
Sourcepub fn instance(&self) -> &InstanceId
pub fn instance(&self) -> &InstanceId
The device identity every flow in this set registers under.
Sourcepub fn add(
&mut self,
endpoint: Handle,
config: Config,
target: Target,
) -> Result<RegId>
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.
Sourcepub fn any_active(&self) -> bool
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.
Sourcepub fn active_flows(&self) -> Vec<RegId>
pub fn active_flows(&self) -> Vec<RegId>
The flows that are up, by reg-id.
Sourcepub async fn register(&mut self) -> Vec<Attempt>
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.
Sourcepub async fn keepalive(&mut self) -> Vec<Attempt>
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.
Sourcepub fn flow(&self, reg_id: RegId) -> Option<&UserAgent>
pub fn flow(&self, reg_id: RegId) -> Option<&UserAgent>
The agent for one flow, for a caller that needs to send through it.
Sourcepub fn retry_after(&self, reg_id: RegId) -> Option<Duration>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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