mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-16 00:00:37 +08:00
node: Add track/untrack support
Signed-off-by: Slack Coder <slackcoder@server.ky>
This commit is contained in:
@@ -54,6 +54,25 @@ pub struct Handle<R: Reactor> {
|
||||
}
|
||||
|
||||
impl<R: Reactor> traits::Handle for Handle<R> {
|
||||
/// Retrieve or update the project from network.
|
||||
fn fetch(&self, _id: ProjId) -> Result<(), Error> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Start tracking the given project. Doesn't do anything if the project is already tracked.
|
||||
fn track(&self, id: ProjId) -> Result<bool, Error> {
|
||||
let (sender, receiver) = chan::bounded(1);
|
||||
self.commands.send(protocol::Command::Track(id, sender))?;
|
||||
receiver.recv().map_err(Error::from)
|
||||
}
|
||||
|
||||
/// Untrack the given project and delete it from storage.
|
||||
fn untrack(&self, id: ProjId) -> Result<bool, Error> {
|
||||
let (sender, receiver) = chan::bounded(1);
|
||||
self.commands.send(protocol::Command::Untrack(id, sender))?;
|
||||
receiver.recv().map_err(Error::from)
|
||||
}
|
||||
|
||||
/// Notify the client that a project has been updated.
|
||||
fn updated(&self, id: ProjId) -> Result<(), Error> {
|
||||
self.command(protocol::Command::AnnounceRefsUpdate(id))
|
||||
@@ -80,6 +99,13 @@ pub mod traits {
|
||||
use super::*;
|
||||
|
||||
pub trait Handle {
|
||||
/// Retrieve or update the project from network.
|
||||
fn fetch(&self, id: ProjId) -> Result<(), Error>;
|
||||
/// Start tracking the given project. Doesn't do anything if the project is already
|
||||
/// tracked.
|
||||
fn track(&self, id: ProjId) -> Result<bool, Error>;
|
||||
/// Untrack the given project and delete it from storage.
|
||||
fn untrack(&self, id: ProjId) -> Result<bool, Error>;
|
||||
/// Notify the client that a project has been updated.
|
||||
fn updated(&self, id: ProjId) -> Result<(), Error>;
|
||||
/// Send a command to the command channel, and wake up the event loop.
|
||||
|
||||
Reference in New Issue
Block a user