• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 4370280743

pending completion
4370280743

push

github

GitHub
Bump async-trait from 0.1.65 to 0.1.66 (#1179)

27808 of 38702 relevant lines covered (71.85%)

25323.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/dozer-cache/src/cache/mod.rs
1
mod lmdb;
2
use std::fmt::Debug;
3

4
use self::expression::QueryExpression;
5
use crate::errors::CacheError;
6
use dozer_types::{
7
    serde::{Deserialize, Serialize},
8
    types::{IndexDefinition, Record, Schema},
9
};
10
pub use lmdb::cache_manager::{CacheManagerOptions, LmdbCacheManager};
11
pub mod expression;
12
pub mod index;
13
mod plan;
14
pub mod test_utils;
15

16
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
63,691✔
17
#[serde(crate = "dozer_types::serde")]
×
18
pub struct RecordWithId {
19
    pub id: u64,
20
    pub record: Record,
21
}
22

23
impl RecordWithId {
24
    pub fn new(id: u64, record: Record) -> Self {
1,132,766✔
25
        Self { id, record }
1,132,766✔
26
    }
1,132,766✔
27
}
×
28

29
pub trait CacheManager: Send + Sync + Debug {
30
    /// Opens a cache in read-write mode with given name or an alias with that name.
31
    ///
32
    /// If the name is both an alias and a real name, it's treated as an alias.
33
    fn open_rw_cache(&self, name: &str) -> Result<Option<Box<dyn RwCache>>, CacheError>;
34

35
    /// Opens a cache in read-only mode with given name or an alias with that name.
36
    ///
37
    /// If the name is both an alias and a real name, it's treated as an alias.
38
    fn open_ro_cache(&self, name: &str) -> Result<Option<Box<dyn RoCache>>, CacheError>;
39

40
    /// Creates a new cache with given `schema`s, which can also be opened in read-only mode using `open_ro_cache`.
41
    ///
42
    /// Schemas cannot be changed after the cache is created.
43
    ///
44
    /// The cache's name is unique.
45
    fn create_cache(
46
        &self,
47
        schema: Schema,
48
        indexes: Vec<IndexDefinition>,
49
    ) -> Result<Box<dyn RwCache>, CacheError>;
50

51
    /// Creates an alias `alias` for a cache with name `name`.
52
    ///
53
    /// If `alias` already exists, it's overwritten. If cache with name `name` doesn't exist, the alias is still recorded.
54
    fn create_alias(&self, name: &str, alias: &str) -> Result<(), CacheError>;
55
}
56

57
pub trait RoCache: Send + Sync + Debug {
58
    /// Returns the name of the cache.
59
    fn name(&self) -> &str;
60

61
    // Schema Operations
62
    fn get_schema(&self) -> Result<&(Schema, Vec<IndexDefinition>), CacheError>;
63

64
    // Record Operations
65
    fn get(&self, key: &[u8]) -> Result<RecordWithId, CacheError>;
66
    fn count(&self, query: &QueryExpression) -> Result<usize, CacheError>;
67
    fn query(&self, query: &QueryExpression) -> Result<Vec<RecordWithId>, CacheError>;
68
}
69

70
pub trait RwCache: RoCache {
71
    // Record Operations
72
    /// Sets the version of the inserted record and inserts it into the cache. Returns the id of the newly inserted record.
73
    fn insert(&self, record: &mut Record) -> Result<u64, CacheError>;
74
    /// Returns version of the deleted record.
75
    fn delete(&self, key: &[u8]) -> Result<u32, CacheError>;
76
    /// Sets the version of the updated record and updates it in the cache. Returns the version of the record before the update.
77
    fn update(&self, key: &[u8], record: &mut Record) -> Result<u32, CacheError>;
78
    /// Commits the current transaction.
79
    fn commit(&self) -> Result<(), CacheError>;
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc