diff --git a/crates/backend/src/local.rs b/crates/backend/src/local.rs index 02cf6c5df..4cce47455 100644 --- a/crates/backend/src/local.rs +++ b/crates/backend/src/local.rs @@ -398,6 +398,11 @@ impl ReadBackend for LocalBackend { Ok(vec.into()) } + + /// [`LocalBackend`] doesn't use `async`, even under the hood. + fn is_async_incompatible(&self) -> bool { + false + } } impl WriteBackend for LocalBackend { diff --git a/crates/backend/src/opendal.rs b/crates/backend/src/opendal.rs index c57b5c7f9..d97fd1fad 100644 --- a/crates/backend/src/opendal.rs +++ b/crates/backend/src/opendal.rs @@ -386,6 +386,15 @@ impl ReadBackend for OpenDALBackend { )? .to_bytes()) } + + /// [`OpenDALBackend`] is `sync` and uses `block_on(async Fn)` under the hood. + /// + /// When implementing `rustic_core` using this backend in some `async` features will not work. + /// + /// see https://github.com/rustic-rs/rustic/issues/1181 + fn is_async_incompatible(&self) -> bool { + true + } } impl WriteBackend for OpenDALBackend { diff --git a/crates/backend/src/rclone.rs b/crates/backend/src/rclone.rs index 94bb4b3ba..4456d0b5c 100644 --- a/crates/backend/src/rclone.rs +++ b/crates/backend/src/rclone.rs @@ -353,6 +353,10 @@ impl ReadBackend for RcloneBackend { ) -> RusticResult { self.rest.read_partial(tpe, id, cacheable, offset, length) } + /// RcloneBackend uses `RestBackend` + fn is_async_incompatible(&self) -> bool { + self.rest.is_async_incompatible() + } } impl WriteBackend for RcloneBackend { diff --git a/crates/backend/src/rest.rs b/crates/backend/src/rest.rs index 2293afa6d..e266ccfac 100644 --- a/crates/backend/src/rest.rs +++ b/crates/backend/src/rest.rs @@ -413,6 +413,16 @@ impl ReadBackend for RestBackend { ) .map_err(construct_backoff_error) } + + /// [`RestBackend`] uses `reqwest` which blocking implementation + /// uses an `async` runtime under the hood. + /// + /// When implementing `rustic_core` using this backend in some `async` features will not work. + /// + /// https://github.com/rustic-rs/rustic/issues/1181 + fn is_async_incompatible(&self) -> bool { + true + } } fn construct_backoff_error(err: backoff::Error) -> Box { diff --git a/crates/core/src/backend/cache.rs b/crates/core/src/backend/cache.rs index 8d82ecb06..59d134537 100644 --- a/crates/core/src/backend/cache.rs +++ b/crates/core/src/backend/cache.rs @@ -162,6 +162,10 @@ impl ReadBackend for CachedBackend { fn warm_up(&self, tpe: FileType, id: &Id) -> RusticResult<()> { self.be.warm_up(tpe, id) } + + fn is_async_incompatible(&self) -> bool { + self.be.is_async_incompatible() + } } impl WriteBackend for CachedBackend { diff --git a/crates/core/src/backend/decrypt.rs b/crates/core/src/backend/decrypt.rs index 35b4f5067..d88eca3d3 100644 --- a/crates/core/src/backend/decrypt.rs +++ b/crates/core/src/backend/decrypt.rs @@ -622,6 +622,10 @@ impl ReadBackend for DecryptBackend { ) -> RusticResult { self.be.read_partial(tpe, id, cacheable, offset, length) } + + fn is_async_incompatible(&self) -> bool { + self.be.is_async_incompatible() + } } impl WriteBackend for DecryptBackend { diff --git a/crates/core/src/backend/dry_run.rs b/crates/core/src/backend/dry_run.rs index 5bd07cb8b..5df9a2d56 100644 --- a/crates/core/src/backend/dry_run.rs +++ b/crates/core/src/backend/dry_run.rs @@ -103,6 +103,10 @@ impl ReadBackend for DryRunBackend { ) -> RusticResult { self.be.read_partial(tpe, id, cacheable, offset, length) } + + fn is_async_incompatible(&self) -> bool { + self.be.is_async_incompatible() + } } impl DecryptWriteBackend for DryRunBackend { diff --git a/crates/core/src/backend/hotcold.rs b/crates/core/src/backend/hotcold.rs index e5306e2f4..8d9cb0898 100644 --- a/crates/core/src/backend/hotcold.rs +++ b/crates/core/src/backend/hotcold.rs @@ -75,6 +75,10 @@ impl ReadBackend for HotColdBackend { fn warm_up(&self, tpe: FileType, id: &Id) -> RusticResult<()> { self.be.warm_up(tpe, id) } + + fn is_async_incompatible(&self) -> bool { + self.be.is_async_incompatible() + } } impl WriteBackend for HotColdBackend { diff --git a/crates/core/src/backend/warm_up.rs b/crates/core/src/backend/warm_up.rs index 3e25d49ae..5fd3e8647 100644 --- a/crates/core/src/backend/warm_up.rs +++ b/crates/core/src/backend/warm_up.rs @@ -59,6 +59,10 @@ impl ReadBackend for WarmUpAccessBackend { _ = self.be.read_partial(tpe, id, false, 0, 1); Ok(()) } + + fn is_async_incompatible(&self) -> bool { + self.be.is_async_incompatible() + } } impl WriteBackend for WarmUpAccessBackend { diff --git a/crates/testing/src/backend.rs b/crates/testing/src/backend.rs index 418bd320f..8c12814f2 100644 --- a/crates/testing/src/backend.rs +++ b/crates/testing/src/backend.rs @@ -58,6 +58,11 @@ pub mod in_memory_backend { ) -> RusticResult { Ok(self.0.read().unwrap()[tpe][id].slice(offset as usize..(offset + length) as usize)) } + + /// [`InMemoryBackend`] doesn't use `async`, even under the hood. + fn is_async_incompatible(&self) -> bool { + false + } } impl WriteBackend for InMemoryBackend {