pub struct StaticProvider { /* private fields */ }
Expand description
A static discovery implementation that allows providing info for nodes manually.
Implementations§
Source§impl StaticProvider
impl StaticProvider
Sourcepub const PROVENANCE: &'static str = "static_discovery"
pub const PROVENANCE: &'static str = "static_discovery"
The provenance string for this discovery implementation.
Sourcepub fn from_node_addrs(
infos: impl IntoIterator<Item = impl Into<NodeAddr>>,
) -> Self
pub fn from_node_addrs( infos: impl IntoIterator<Item = impl Into<NodeAddr>>, ) -> Self
Creates a static discovery instance from something that can be converted into node addresses.
Example:
use std::str::FromStr;
use iroh_base::ticket::NodeTicket;
use iroh_net::{Endpoint, discovery::static_provider::StaticProvider};
// get tickets from command line args
let tickets: Vec<NodeTicket> = args.tickets;
// create a StaticProvider from the tickets. Ticket info will be combined if multiple tickets refer to the same node.
let discovery = StaticProvider::from_node_addrs(tickets);
// create an endpoint with the discovery
let endpoint = Endpoint::builder()
.add_discovery(|_| Some(discovery))
.bind().await?;
Sourcepub fn set_node_addr(&self, info: impl Into<NodeAddr>) -> Option<NodeAddr>
pub fn set_node_addr(&self, info: impl Into<NodeAddr>) -> Option<NodeAddr>
Add node info for the given node id.
This will completely overwrite any existing info for the node.
Sourcepub fn add_node_addr(&self, info: impl Into<NodeAddr>)
pub fn add_node_addr(&self, info: impl Into<NodeAddr>)
Add node info for the given node id, combining it with any existing info.
This will add any new direct addresses and overwrite the relay url.
Sourcepub fn get_node_addr(&self, node_id: NodeId) -> Option<NodeAddr>
pub fn get_node_addr(&self, node_id: NodeId) -> Option<NodeAddr>
Get node info for the given node id.
Sourcepub fn remove_node_addr(&self, node_id: NodeId) -> Option<NodeAddr>
pub fn remove_node_addr(&self, node_id: NodeId) -> Option<NodeAddr>
Remove node info for the given node id.
Trait Implementations§
Source§impl Debug for StaticProvider
impl Debug for StaticProvider
Source§impl Default for StaticProvider
impl Default for StaticProvider
Source§fn default() -> StaticProvider
fn default() -> StaticProvider
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StaticProvider
impl RefUnwindSafe for StaticProvider
impl Send for StaticProvider
impl Sync for StaticProvider
impl Unpin for StaticProvider
impl UnwindSafe for StaticProvider
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
Mutably borrows from an owned value. Read more