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 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.
Trait Implementations§
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.
impl Eq for RelayMap
Auto Trait Implementations§
impl Freeze for RelayMap
impl RefUnwindSafe for RelayMap
impl Send for RelayMap
impl Sync for RelayMap
impl Unpin 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§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<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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.