Implement `Handle::listening`

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-10-18 12:37:19 +02:00
parent d3523ccf78
commit 2499317589
No known key found for this signature in database
2 changed files with 10 additions and 0 deletions

View File

@ -56,6 +56,10 @@ pub struct Handle<W: Waker> {
}
impl<W: Waker> traits::Handle for Handle<W> {
fn listening(&self) -> Result<net::SocketAddr, Error> {
self.listening.recv().map_err(Error::from)
}
/// Retrieve or update the given project from the network.
fn fetch(&self, id: Id) -> Result<FetchLookup, Error> {
let (sender, receiver) = chan::bounded(1);
@ -142,6 +146,8 @@ pub mod traits {
use super::*;
pub trait Handle {
/// Wait for the node's listening socket to be bound.
fn listening(&self) -> Result<net::SocketAddr, Error>;
/// Retrieve or update the project from network.
fn fetch(&self, id: Id) -> Result<FetchLookup, Error>;
/// Start tracking the given project. Doesn't do anything if the project is already

View File

@ -14,6 +14,10 @@ pub struct Handle {
}
impl traits::Handle for Handle {
fn listening(&self) -> Result<std::net::SocketAddr, Error> {
unimplemented!()
}
fn fetch(&self, _id: Id) -> Result<FetchLookup, Error> {
Ok(FetchLookup::NotFound)
}