pub struct RelayMap { /* private fields */ }Expand description
List of relay server configurations to be used in an iroh endpoint.
A RelayMap can be constructed from an iterator of RelayConfig or [RelayUrl],
or by creating an empty relay map with RelayMap::empty and then adding entries with
RelayMap::insert.
Example:
let relay1 = RelayUrl::from_str("https://relay1.example.org").unwrap();
let relay2 = RelayUrl::from_str("https://relay2.example.org").unwrap();
let map = RelayMap::from_iter(vec![relay1, relay2]);Implementations§
Source§impl RelayMap
impl RelayMap
Sourcepub fn try_from_iter<'a, T: IntoIterator<Item = &'a str>>(
urls: T,
) -> Result<Self, RelayUrlParseError>
pub fn try_from_iter<'a, T: IntoIterator<Item = &'a str>>( urls: T, ) -> Result<Self, RelayUrlParseError>
Creates a RelayMap from an iterator.
The conversion from a URL to a RelayConfig is done the same as when parsing it directly,
which means it is assumed to run QUIC on default settings as defined in RelayQuicConfig::default.
§Example
let map =
RelayMap::try_from_iter(["https://relay_0.cool.com", "https://relay_1.cool.com"]).unwrap();Sourcepub fn urls<T>(&self) -> Twhere
T: FromIterator<RelayUrl>,
pub fn urls<T>(&self) -> Twhere
T: FromIterator<RelayUrl>,
Returns the URLs of all servers in this relay map.
This function is generic over the container to collect into. If you simply want a list
of URLs, call this with map.urls::<Vec<_>>() to get a Vec<RelayUrl>.
Sourcepub fn relays<T>(&self) -> T
pub fn relays<T>(&self) -> T
Returns a list with the RelayConfig for each relay in this relay map.
This function is generic over the container to collect into. If you simply want a list
of URLs, call this with map.relays::<Vec<_>>() to get a Vec<RelayConfig>.
Sourcepub fn contains(&self, url: &RelayUrl) -> bool
pub fn contains(&self, url: &RelayUrl) -> bool
Returns true if a relay with url is contained in this this relay map.
Sourcepub fn insert(
&self,
url: RelayUrl,
endpoint: Arc<RelayConfig>,
) -> Option<Arc<RelayConfig>>
pub fn insert( &self, url: RelayUrl, endpoint: Arc<RelayConfig>, ) -> Option<Arc<RelayConfig>>
Inserts a new relay into the relay map.
Sourcepub fn remove(&self, url: &RelayUrl) -> Option<Arc<RelayConfig>>
pub fn remove(&self, url: &RelayUrl) -> Option<Arc<RelayConfig>>
Removes an existing relay by its URL.
Sourcepub fn with_auth_token(self, auth_token: impl Into<String>) -> Self
pub fn with_auth_token(self, auth_token: impl Into<String>) -> Self
Sets an authorization token for all relays configured in this relay map.
This applies RelayConfig::with_auth_token to all current entries in this relay map.
Any entries added to this relay map after calling this will not have the token set.
See RelayConfig::with_auth_token for details.
Trait Implementations§
impl Eq for RelayMap
Source§impl From<RelayConfig> for RelayMap
impl From<RelayConfig> for RelayMap
Source§fn from(value: RelayConfig) -> Self
fn from(value: RelayConfig) -> Self
Source§impl FromIterator<Arc<RelayConfig>> for RelayMap
impl FromIterator<Arc<RelayConfig>> for RelayMap
Source§fn from_iter<T: IntoIterator<Item = Arc<RelayConfig>>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Arc<RelayConfig>>>(iter: T) -> Self
Source§impl FromIterator<RelayConfig> for RelayMap
impl FromIterator<RelayConfig> for RelayMap
Source§fn from_iter<T: IntoIterator<Item = RelayConfig>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = RelayConfig>>(iter: T) -> Self
Source§impl FromIterator<RelayUrl> for RelayMap
impl FromIterator<RelayUrl> for RelayMap
Source§fn from_iter<T: IntoIterator<Item = RelayUrl>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = RelayUrl>>(iter: T) -> Self
Creates a RelayMap from an iterator of RelayUrl.
The RelayConfigs in the RelayMap will have the default QUIC address
discovery ports.
Auto Trait Implementations§
impl Freeze for RelayMap
impl RefUnwindSafe for RelayMap
impl Send for RelayMap
impl Sync for RelayMap
impl Unpin for RelayMap
impl UnsafeUnpin for RelayMap
impl UnwindSafe for RelayMap
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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