Nathan.fooo 609ea27c42
fix: write/load database/document collab (#6308)
* chore: post document collab after create

* chore: write database rows

* chore: fix test

* chore: fix test

* chore: bump collab

* chore: fix get related row

* chore: try to fix open database error

* chore: update client api
2024-09-15 00:02:17 +08:00

46 lines
1.1 KiB
Rust

use anyhow::Error;
use collab::entity::EncodedCollab;
pub use collab_document::blocks::DocumentData;
use flowy_error::FlowyError;
use lib_infra::async_trait::async_trait;
/// A trait for document cloud service.
/// Each kind of server should implement this trait. Check out the [AppFlowyServerProvider] of
/// [flowy-server] crate for more information.
#[async_trait]
pub trait DocumentCloudService: Send + Sync + 'static {
async fn get_document_doc_state(
&self,
document_id: &str,
workspace_id: &str,
) -> Result<Vec<u8>, FlowyError>;
async fn get_document_snapshots(
&self,
document_id: &str,
limit: usize,
workspace_id: &str,
) -> Result<Vec<DocumentSnapshot>, Error>;
async fn get_document_data(
&self,
document_id: &str,
workspace_id: &str,
) -> Result<Option<DocumentData>, Error>;
async fn create_document_collab(
&self,
workspace_id: &str,
document_id: &str,
encoded_collab: EncodedCollab,
) -> Result<(), Error>;
}
pub struct DocumentSnapshot {
pub snapshot_id: i64,
pub document_id: String,
pub data: Vec<u8>,
pub created_at: i64,
}