rustic_core
rustic_core copied to clipboard
how to Pause or Cancel when you call `repo.backup()` ?
how to Pause or Cancel when you call repo.backup() ?
I saw that the source code implementation used a blocking API.
Can you consider using tokio, as JoinHandle supports the use of asynchronous functions to forcibly cancel externally.
and.... At present, most libraries use async. If I want to support a backend myself
for example:
let handle = tokio::spawn(async{
repo.backup().await
});
//cancel this
handle.abort();
currently The way for me to cancel a task is to use panic in the inc function of Progress to stop the task
#[derive(Clone, Debug)]
pub struct MProgress {
pub control: Arc<AtomicI32>
}
impl Progress for MProgress {
fn is_hidden(&self) -> bool {
false
}
fn set_length(&self, _len: u64) {
}
fn set_title(&self, title: &'static str) {
}
fn inc(&self, inc: u64) {
if self.control.load(Ordering::Relaxed) == -1{
panic!("cancel");
}
}
fn finish(&self) {
}
}