pub struct EndpointData { /* private fields */ }Expand description
Data about an endpoint that may be published to and resolved from discovery services.
This includes an optional RelayUrl, a set of direct addresses, and the optional
UserData, a string that can be set by applications and is not parsed or used by iroh
itself.
This struct does not include the endpoint’s EndpointId, only the data about a certain
endpoint. See EndpointInfo for a struct that contains a EndpointId with associated EndpointData.
Implementations§
Source§impl EndpointData
impl EndpointData
Sourcepub fn new(addrs: Vec<TransportAddr>) -> Self
pub fn new(addrs: Vec<TransportAddr>) -> Self
Creates a new EndpointData with given list of transport addresses.
The address order is preserved, so it can encode priority for address lookup services, should they not fit into e.g. a single DNS packet otherwise.
If the addresses contain duplicate entries, those entries are removed.
Sourcepub fn with_user_data(self, user_data: UserData) -> Self
pub fn with_user_data(self, user_data: UserData) -> Self
Sets the user-defined data and returns the updated endpoint info.
Useful for calling on construction after EndpointData::new or EndpointData::from_iter.
See also Self::set_user_data.
Sourcepub fn add_relay_url(&mut self, relay_url: RelayUrl)
pub fn add_relay_url(&mut self, relay_url: RelayUrl)
Adds the relay URL to the end of the endpoint data, unless it already existed.
Sourcepub fn add_ip_addrs(&mut self, addresses: Vec<SocketAddr>)
pub fn add_ip_addrs(&mut self, addresses: Vec<SocketAddr>)
Adds addresses in order with duplicates or already existing addresses filtered out.
Sourcepub fn add_addrs(&mut self, addrs: impl IntoIterator<Item = TransportAddr>)
pub fn add_addrs(&mut self, addrs: impl IntoIterator<Item = TransportAddr>)
Adds addresses to the endpoint data in the given order, but with duplicates filtered.
Sourcepub fn set_user_data(&mut self, user_data: Option<UserData>)
pub fn set_user_data(&mut self, user_data: Option<UserData>)
Sets the user-defined data.
Sourcepub fn clear_ip_addrs(&mut self)
pub fn clear_ip_addrs(&mut self)
Removes all direct addresses from the endpoint data.
Sourcepub fn clear_relay_urls(&mut self)
pub fn clear_relay_urls(&mut self)
Removes all relay URLs from the endpoint data.
Sourcepub fn relay_urls(&self) -> impl Iterator<Item = &RelayUrl>
pub fn relay_urls(&self) -> impl Iterator<Item = &RelayUrl>
Returns the relay URL of the endpoint.
Sourcepub fn user_data(&self) -> Option<&UserData>
pub fn user_data(&self) -> Option<&UserData>
Returns the optional user-defined data of the endpoint.
Sourcepub fn ip_addrs(&self) -> impl Iterator<Item = &SocketAddr>
pub fn ip_addrs(&self) -> impl Iterator<Item = &SocketAddr>
Returns the direct addresses of the endpoint.
Sourcepub fn addrs(&self) -> impl Iterator<Item = &TransportAddr>
pub fn addrs(&self) -> impl Iterator<Item = &TransportAddr>
Returns the full list of all known addresses.
Sourcepub fn filtered_addrs(&self, filter: &AddrFilter) -> Cow<'_, Vec<TransportAddr>>
pub fn filtered_addrs(&self, filter: &AddrFilter) -> Cow<'_, Vec<TransportAddr>>
Apply the given filter to the current addresses.
Returns a vec to allow re-ordering of addresses.
Sourcepub fn apply_filter(&self, filter: &AddrFilter) -> Cow<'_, Self>
pub fn apply_filter(&self, filter: &AddrFilter) -> Cow<'_, Self>
Returns the EndpointData with given filter applied.
Trait Implementations§
Source§impl Clone for EndpointData
impl Clone for EndpointData
Source§fn clone(&self) -> EndpointData
fn clone(&self) -> EndpointData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EndpointData
impl Debug for EndpointData
Source§impl Default for EndpointData
impl Default for EndpointData
Source§fn default() -> EndpointData
fn default() -> EndpointData
Source§impl From<BTreeSet<SocketAddr>> for EndpointData
impl From<BTreeSet<SocketAddr>> for EndpointData
Source§fn from(addrs: BTreeSet<SocketAddr>) -> Self
fn from(addrs: BTreeSet<SocketAddr>) -> Self
Source§impl From<BTreeSet<TransportAddr>> for EndpointData
impl From<BTreeSet<TransportAddr>> for EndpointData
Source§fn from(addrs: BTreeSet<TransportAddr>) -> Self
fn from(addrs: BTreeSet<TransportAddr>) -> Self
Source§impl From<EndpointAddr> for EndpointData
impl From<EndpointAddr> for EndpointData
Source§fn from(endpoint_addr: EndpointAddr) -> Self
fn from(endpoint_addr: EndpointAddr) -> Self
Source§impl FromIterator<TransportAddr> for EndpointData
impl FromIterator<TransportAddr> for EndpointData
Source§fn from_iter<T: IntoIterator<Item = TransportAddr>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = TransportAddr>>(iter: T) -> Self
Source§impl PartialEq for EndpointData
impl PartialEq for EndpointData
impl Eq for EndpointData
impl StructuralPartialEq for EndpointData
Auto Trait Implementations§
impl Freeze for EndpointData
impl RefUnwindSafe for EndpointData
impl Send for EndpointData
impl Sync for EndpointData
impl Unpin for EndpointData
impl UnwindSafe for EndpointData
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
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.