Implement `Handle::listening`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
d3523ccf78
commit
2499317589
|
|
@ -56,6 +56,10 @@ pub struct Handle<W: Waker> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Waker> traits::Handle for Handle<W> {
|
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.
|
/// Retrieve or update the given project from the network.
|
||||||
fn fetch(&self, id: Id) -> Result<FetchLookup, Error> {
|
fn fetch(&self, id: Id) -> Result<FetchLookup, Error> {
|
||||||
let (sender, receiver) = chan::bounded(1);
|
let (sender, receiver) = chan::bounded(1);
|
||||||
|
|
@ -142,6 +146,8 @@ pub mod traits {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub trait Handle {
|
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.
|
/// Retrieve or update the project from network.
|
||||||
fn fetch(&self, id: Id) -> Result<FetchLookup, Error>;
|
fn fetch(&self, id: Id) -> Result<FetchLookup, Error>;
|
||||||
/// Start tracking the given project. Doesn't do anything if the project is already
|
/// Start tracking the given project. Doesn't do anything if the project is already
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ pub struct Handle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl traits::Handle for Handle {
|
impl traits::Handle for Handle {
|
||||||
|
fn listening(&self) -> Result<std::net::SocketAddr, Error> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
fn fetch(&self, _id: Id) -> Result<FetchLookup, Error> {
|
fn fetch(&self, _id: Id) -> Result<FetchLookup, Error> {
|
||||||
Ok(FetchLookup::NotFound)
|
Ok(FetchLookup::NotFound)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue