mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 10:21:53 +00:00
dump type
This commit is contained in:
committed by
Aiden McClelland
parent
b5cf9f28ba
commit
8bc6a3a1a5
@@ -14,6 +14,13 @@ pub struct Revision {
|
||||
pub expire_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Dump {
|
||||
pub id: u64,
|
||||
pub value: Value,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DiffPatch(Patch);
|
||||
impl DiffPatch {
|
||||
|
||||
@@ -15,7 +15,7 @@ use tokio::fs::File;
|
||||
use tokio::sync::broadcast::{Receiver, Sender};
|
||||
use tokio::sync::{Mutex, RwLock, RwLockWriteGuard};
|
||||
|
||||
use crate::patch::{diff, DiffPatch, Revision};
|
||||
use crate::patch::{diff, DiffPatch, Dump, Revision};
|
||||
use crate::Error;
|
||||
use crate::{locker::Locker, PatchDbHandle};
|
||||
|
||||
@@ -146,8 +146,11 @@ impl Store {
|
||||
ptr.get(self.get_data()?).unwrap_or(&Value::Null).clone(),
|
||||
)?)
|
||||
}
|
||||
pub(crate) fn dump(&self) -> Value {
|
||||
self.get_data().unwrap().clone()
|
||||
pub(crate) fn dump(&self) -> Dump {
|
||||
Dump {
|
||||
id: self.revision,
|
||||
value: self.get_data().unwrap().clone(),
|
||||
}
|
||||
}
|
||||
pub(crate) async fn put<T: Serialize + ?Sized, S: AsRef<str>, V: SegList>(
|
||||
&mut self,
|
||||
@@ -214,7 +217,7 @@ impl PatchDb {
|
||||
subscriber: Arc::new(subscriber),
|
||||
})
|
||||
}
|
||||
pub async fn dump(&self) -> Value {
|
||||
pub async fn dump(&self) -> Dump {
|
||||
self.store.read().await.dump()
|
||||
}
|
||||
pub async fn exists<S: AsRef<str>, V: SegList>(
|
||||
|
||||
Reference in New Issue
Block a user