51 lines
1.6 KiB
Rust
Raw Normal View History

2022-03-10 17:14:10 +08:00
mod folder_rev_impl;
mod grid_rev_impl;
mod text_block_rev_impl;
pub use folder_rev_impl::*;
pub use grid_rev_impl::*;
pub use text_block_rev_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;
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;
2022-01-26 23:29:18 +08:00
fn create_revision_records(
2022-01-04 15:05:52 +08:00
&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, object_id: &str, rev_ids: Option<Vec<i64>>) -> Result<(), Self::Error>;
2022-01-04 15:05:52 +08:00
2022-01-26 23:29:18 +08:00
// Delete and insert will be executed in the same transaction.
// It deletes all the records if the deleted_rev_ids is None and then insert the new records
fn delete_and_insert_records(
&self,
object_id: &str,
deleted_rev_ids: Option<Vec<i64>>,
inserted_records: Vec<RevisionRecord>,
) -> Result<(), Self::Error>;
2022-01-04 15:05:52 +08:00
}