pub struct RelayStatus { /* private fields */ }Expand description
Connection status of a single home relay.
Observed via Endpoint::home_relay_status.
Implementations§
Source§impl RelayStatus
impl RelayStatus
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns true if the endpoint is connected to the relay.
Sourcepub fn last_error(&self) -> Option<&AnyError>
pub fn last_error(&self) -> Option<&AnyError>
Returns the most recent connection error.
Returns None when the relay is connected, or when the endpoint has
not yet observed a failed connection attempt.
The error is meant to be logged or displayed, not matched on: it is an
[AnyError] wrapping a chain of private error types, none of which are
covered by semver guarantees. Use Self::auth_denied_reason to
distinguish the one failure that usually calls for a different reaction
than retrying.
Sourcepub fn auth_denied_reason(&self) -> Option<&str>
pub fn auth_denied_reason(&self) -> Option<&str>
Returns the reason if the relay server denied our authentication.
Unlike most connection failures, this one will not usually resolve
itself. The endpoint keeps retrying with a backoff, but it presents the
same credentials every time, so unless the relay’s access policy
changes it will keep being denied and Endpoint::online will never
resolve. An application that configures a relay auth token should
surface this to the user rather than wait to come online.
The returned string is the reason reported by the relay server. It is meant to be human-readable, don’t attempt to match on it.
Returns None when the relay is connected, when no connection attempt
has failed yet, or when the last failure had another cause.
use iroh::{Endpoint, Watcher, endpoint::presets};
use n0_future::StreamExt;
let endpoint = Endpoint::builder(presets::Minimal).bind().await?;
let mut status = endpoint.home_relay_status().stream();
while let Some(relays) = status.next().await {
for relay in relays {
if let Some(reason) = relay.auth_denied_reason() {
println!("{}: authentication denied ({reason})", relay.url());
}
}
}Trait Implementations§
Source§impl Clone for RelayStatus
impl Clone for RelayStatus
Source§fn clone(&self) -> RelayStatus
fn clone(&self) -> RelayStatus
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RelayStatus
impl Debug for RelayStatus
Source§impl PartialEq for RelayStatus
impl PartialEq for RelayStatus
impl Eq for RelayStatus
impl StructuralPartialEq for RelayStatus
Auto Trait Implementations§
impl Freeze for RelayStatus
impl !RefUnwindSafe for RelayStatus
impl Send for RelayStatus
impl Sync for RelayStatus
impl Unpin for RelayStatus
impl !UnwindSafe for RelayStatus
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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