44 lines
1.3 KiB
Rust
Raw Normal View History

2022-01-04 15:05:52 +08:00
mod sql_impl;
2022-01-14 15:23:21 +08:00
use crate::RevisionRecord;
2022-01-04 15:05:52 +08:00
use diesel::SqliteConnection;
use flowy_collaboration::entities::revision::RevisionRange;
pub use sql_impl::*;
use flowy_error::FlowyResult;
use std::fmt::Debug;
2022-01-14 15:23:21 +08:00
pub trait RevisionDiskCache: Sync + Send {
2022-01-04 15:05:52 +08:00
type Error: Debug;
fn write_revision_records(
&self,
2022-01-14 15:23:21 +08:00
revision_records: Vec<RevisionRecord>,
2022-01-04 15:05:52 +08:00
conn: &SqliteConnection,
) -> Result<(), Self::Error>;
// Read all the records if the rev_ids is None
fn read_revision_records(
&self,
2022-01-14 15:23:21 +08:00
object_id: &str,
2022-01-04 15:05:52 +08:00
rev_ids: Option<Vec<i64>>,
) -> Result<Vec<RevisionRecord>, Self::Error>;
2022-01-25 20:37:48 +08:00
// Read the revision which rev_id >= range.start && rev_id <= range.end
2022-01-04 15:05:52 +08:00
fn read_revision_records_with_range(
&self,
2022-01-14 15:23:21 +08:00
object_id: &str,
2022-01-04 15:05:52 +08:00
range: &RevisionRange,
) -> Result<Vec<RevisionRecord>, Self::Error>;
fn update_revision_record(&self, changesets: Vec<RevisionChangeset>) -> FlowyResult<()>;
// Delete all the records if the rev_ids is None
fn delete_revision_records(
&self,
2022-01-14 15:23:21 +08:00
object_id: &str,
2022-01-04 15:05:52 +08:00
rev_ids: Option<Vec<i64>>,
conn: &SqliteConnection,
) -> Result<(), Self::Error>;
2022-01-14 15:23:21 +08:00
fn reset_object(&self, object_id: &str, revision_records: Vec<RevisionRecord>) -> Result<(), Self::Error>;
2022-01-04 15:05:52 +08:00
}