pub struct Discovery { /* private fields */ }Expand description
LAN discovery service using UDP broadcast.
Implementations§
Source§impl Discovery
impl Discovery
Sourcepub async fn start(
node_id: &NodeId,
quic_port: u16,
) -> Result<Self, Box<dyn Error + Send + Sync>>
pub async fn start( node_id: &NodeId, quic_port: u16, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Start the discovery service.
Sourcepub async fn send_beacon(&self) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn send_beacon(&self) -> Result<(), Box<dyn Error + Send + Sync>>
Send a single discovery beacon.
Sourcepub async fn listen_once(
&self,
) -> Result<Option<DiscoveredPeer>, Box<dyn Error + Send + Sync>>
pub async fn listen_once( &self, ) -> Result<Option<DiscoveredPeer>, Box<dyn Error + Send + Sync>>
Listen for a single beacon and register the peer.
Sourcepub fn known_peers(&self) -> Vec<DiscoveredPeer>
pub fn known_peers(&self) -> Vec<DiscoveredPeer>
Get all currently known peers.
Sourcepub fn spawn_background(
self: Arc<Self>,
beacon_interval: Duration,
) -> Receiver<DiscoveredPeer>
pub fn spawn_background( self: Arc<Self>, beacon_interval: Duration, ) -> Receiver<DiscoveredPeer>
Spawn the background beacon + listener tasks. Returns a channel that emits newly discovered peers.
Auto Trait Implementations§
impl Freeze for Discovery
impl !RefUnwindSafe for Discovery
impl Send for Discovery
impl Sync for Discovery
impl Unpin for Discovery
impl UnsafeUnpin for Discovery
impl !UnwindSafe for Discovery
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
Mutably borrows from an owned value. Read more