snapshot of https://github.com/ActivityWatch/aw-server-rust.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build / ubuntu-latest (push) Failing after 5s
Build / Android (push) Failing after 2s
Build / Code coverage (push) Failing after 2s
Lint / format (push) Failing after 3s
Lint / clippy (push) Failing after 3s
Build / macOS-latest (push) Has been cancelled
Build / windows-latest (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-16 00:19:17 +05:00
commit da934b693c
120 changed files with 26659 additions and 0 deletions

61
aw-datastore/src/lib.rs Normal file
View File

@@ -0,0 +1,61 @@
#[macro_use]
extern crate log;
use std::fmt;
#[macro_export]
macro_rules! json_map {
{ $( $key:literal : $value:expr),* } => {{
use serde_json::Value;
use serde_json::map::Map;
#[allow(unused_mut)]
let mut map : Map<String, Value> = Map::new();
$(
map.insert( $key.to_string(), json!($value) );
)*
map
}};
}
mod datastore;
mod export;
mod legacy_import;
mod privacy_filter;
mod worker;
pub use self::datastore::DatastoreInstance;
pub use self::worker::Datastore;
#[derive(Clone)]
pub enum DatastoreMethod {
Memory(),
File(String),
/// Encrypted SQLite file using SQLCipher. Only available with the
/// `encryption` or `encryption-vendored` feature flags.
#[cfg(any(feature = "encryption", feature = "encryption-vendored"))]
FileEncrypted(String, zeroize::Zeroizing<String>), // (path, key)
}
impl fmt::Debug for DatastoreMethod {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
DatastoreMethod::Memory() => write!(f, "Memory()"),
DatastoreMethod::File(p) => write!(f, "File({p:?})"),
#[cfg(any(feature = "encryption", feature = "encryption-vendored"))]
DatastoreMethod::FileEncrypted(p, _) => write!(f, "FileEncrypted({p:?}, <redacted>)"),
}
}
}
/* TODO: Implement this as a proper error */
#[derive(Debug, Clone)]
pub enum DatastoreError {
NoSuchBucket(String),
BucketAlreadyExists(String),
NoSuchKey(String),
MpscError,
InternalError(String),
// Errors specific to when migrate is disabled
Uninitialized(String),
OldDbVersion(String),
}