Struct deltachat::imex::BackupProvider
source · pub struct BackupProvider {
handle: JoinHandle<Result<()>>,
ticket: Ticket,
_drop_guard: DropGuard,
}
Expand description
Provide or send a backup of this device.
This creates a backup of the current device and starts a service which offers another device to download this backup.
This does not make a full backup on disk, only the SQLite database is created on disk, the blobs in the blob directory are not copied.
This starts a task which acquires the global “ongoing” mutex. If you need to stop the
task use the Context::stop_ongoing
mechanism.
The task implements Future
and awaiting it will complete once a transfer has been
either completed or aborted.
Fields§
§handle: JoinHandle<Result<()>>
The supervisor task, run by BackupProvider::watch_provider
.
ticket: Ticket
The ticket to retrieve the backup collection.
_drop_guard: DropGuard
Guard to cancel the provider on drop.
Implementations§
source§impl BackupProvider
impl BackupProvider
sourcepub async fn prepare(context: &Context) -> Result<Self>
pub async fn prepare(context: &Context) -> Result<Self>
Prepares for sending a backup to a second device.
Before calling this function all I/O must be stopped so that no changes to the blobs
or database are happening, this is done by calling the Accounts::stop_io
or
Context::stop_io
APIs first.
This will acquire the global “ongoing process” mutex, which can be used to cancel the process.
sourceasync fn prepare_inner(
context: &Context,
dbfile: &Path
) -> Result<(Provider, Ticket)>
async fn prepare_inner( context: &Context, dbfile: &Path ) -> Result<(Provider, Ticket)>
Creates the provider task.
Having this as a function makes it easier to cancel it when needed.
sourceasync fn watch_provider(
context: &Context,
provider: Provider,
cancel_token: Receiver<()>,
drop_token: CancellationToken
) -> Result<()>
async fn watch_provider( context: &Context, provider: Provider, cancel_token: Receiver<()>, drop_token: CancellationToken ) -> Result<()>
Supervises the iroh [Provider
], terminating it when needed.
This will watch the provider and terminate it when:
- A transfer is completed, successful or unsuccessful.
- An event could not be observed to protect against not knowing of a completed event.
- The ongoing process is cancelled.
The cancel_token is the handle for the ongoing process mutex, when this completes we must cancel this operation.
sourcepub fn qr(&self) -> Qr
pub fn qr(&self) -> Qr
Returns a QR code that allows fetching this backup.
This QR code can be passed to get_backup
on a (different) device.
Trait Implementations§
source§impl Debug for BackupProvider
impl Debug for BackupProvider
source§impl Future for BackupProvider
impl Future for BackupProvider
Auto Trait Implementations§
impl RefUnwindSafe for BackupProvider
impl Send for BackupProvider
impl Sync for BackupProvider
impl Unpin for BackupProvider
impl UnwindSafe for BackupProvider
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<F> FutureExt for F
impl<F> FutureExt for F
§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
§impl<F> FutureExt for Fwhere
F: Future,
impl<F> FutureExt for Fwhere
F: Future,
§fn timeout_at<T>(self, target: T) -> TimeoutAt<Self>
fn timeout_at<T>(self, target: T) -> TimeoutAt<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read more§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read more§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
§type IntoFuture = F
type IntoFuture = F
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
§impl<F, T, E> TryFuture for F
impl<F, T, E> TryFuture for F
§impl<Fut> TryFutureExt for Futwhere
Fut: TryFuture + ?Sized,
impl<Fut> TryFutureExt for Futwhere
Fut: TryFuture + ?Sized,
§fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>where
Self::Ok: Sink<Item, Error = Self::Error>,
Self: Sized,
fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>where
Self::Ok: Sink<Item, Error = Self::Error>,
Self: Sized,
Sink
]. Read more