Merge pull request #260 from rustic-rs/remove-ambassador

Remove dependency on ambassador
This commit is contained in:
aawsome 2022-10-15 00:04:10 +02:00 committed by GitHub
commit db34cb1af8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 17 deletions

12
Cargo.lock generated
View File

@ -53,17 +53,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "ambassador"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61874b33258f18ca7923047c12887078ccfe95c2811b03c1a09e309c19b7e50b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "android_system_properties"
version = "0.1.5"
@ -1571,7 +1560,6 @@ name = "rustic-rs"
version = "0.3.2-dev"
dependencies = [
"aes256ctr_poly1305aes",
"ambassador",
"anyhow",
"async-recursion",
"async-trait",

View File

@ -26,7 +26,6 @@ strip = true
async-trait = "0.1"
async-recursion = "1"
anyhow = "1"
ambassador = "0.2"
thiserror = "1"
derive_more = "0.99"
derivative = "2"

View File

@ -1,7 +1,6 @@
use std::num::NonZeroU32;
use std::sync::Arc;
use ambassador::{delegatable_trait, Delegate};
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use bytes::Bytes;
@ -64,7 +63,6 @@ impl IndexEntry {
}
}
#[delegatable_trait]
pub trait ReadIndex {
fn get_id(&self, tpe: &BlobType, id: &Id) -> Option<IndexEntry>;
fn total_size(&self, tpe: &BlobType) -> u64;
@ -104,13 +102,22 @@ pub trait IndexedBackend: ReadIndex + Clone + Sync + Send + 'static {
}
}
#[derive(Clone, Delegate)]
#[delegate(ReadIndex, target = "index")]
#[derive(Clone)]
pub struct IndexBackend<BE: DecryptReadBackend> {
be: BE,
index: Arc<Index>,
}
impl<BE: DecryptReadBackend> ReadIndex for IndexBackend<BE> {
fn get_id(&self, tpe: &BlobType, id: &Id) -> Option<IndexEntry> {
self.index.get_id(tpe, id)
}
fn total_size(&self, tpe: &BlobType) -> u64 {
self.index.total_size(tpe)
}
}
impl<BE: DecryptReadBackend> IndexBackend<BE> {
pub fn new_from_index(be: &BE, index: Index) -> Self {
Self {