2023-07-29 09:46:24 +08:00
|
|
|
use anyhow::Error;
|
|
|
|
pub use collab_document::blocks::DocumentData;
|
|
|
|
|
2023-11-05 14:00:24 +08:00
|
|
|
use flowy_error::FlowyError;
|
2023-07-29 09:46:24 +08:00
|
|
|
use lib_infra::future::FutureResult;
|
|
|
|
|
|
|
|
/// 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.
|
|
|
|
pub trait DocumentCloudService: Send + Sync + 'static {
|
2023-10-23 11:43:31 +08:00
|
|
|
fn get_document_updates(
|
|
|
|
&self,
|
|
|
|
document_id: &str,
|
|
|
|
workspace_id: &str,
|
2023-11-05 14:00:24 +08:00
|
|
|
) -> FutureResult<Vec<Vec<u8>>, FlowyError>;
|
2023-07-29 09:46:24 +08:00
|
|
|
|
2023-08-17 23:46:39 +08:00
|
|
|
fn get_document_snapshots(
|
2023-07-29 09:46:24 +08:00
|
|
|
&self,
|
|
|
|
document_id: &str,
|
2023-08-17 23:46:39 +08:00
|
|
|
limit: usize,
|
2023-10-23 11:43:31 +08:00
|
|
|
workspace_id: &str,
|
2023-08-17 23:46:39 +08:00
|
|
|
) -> FutureResult<Vec<DocumentSnapshot>, Error>;
|
2023-07-29 09:46:24 +08:00
|
|
|
|
2023-10-23 11:43:31 +08:00
|
|
|
fn get_document_data(
|
|
|
|
&self,
|
|
|
|
document_id: &str,
|
|
|
|
workspace_id: &str,
|
|
|
|
) -> FutureResult<Option<DocumentData>, Error>;
|
2023-07-29 09:46:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct DocumentSnapshot {
|
|
|
|
pub snapshot_id: i64,
|
|
|
|
pub document_id: String,
|
|
|
|
pub data: Vec<u8>,
|
|
|
|
pub created_at: i64,
|
|
|
|
}
|