cloud.rs 1010 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. use std::collections::HashMap;
  2. use anyhow::Error;
  3. use collab_define::CollabType;
  4. use lib_infra::future::FutureResult;
  5. pub type CollabObjectUpdateByOid = HashMap<String, CollabObjectUpdate>;
  6. pub type CollabObjectUpdate = Vec<Vec<u8>>;
  7. /// A trait for database cloud service.
  8. /// Each kind of server should implement this trait. Check out the [AppFlowyServerProvider] of
  9. /// [flowy-server] crate for more information.
  10. pub trait DatabaseCloudService: Send + Sync {
  11. fn get_collab_update(
  12. &self,
  13. object_id: &str,
  14. collab_type: CollabType,
  15. ) -> FutureResult<CollabObjectUpdate, Error>;
  16. fn batch_get_collab_updates(
  17. &self,
  18. object_ids: Vec<String>,
  19. object_ty: CollabType,
  20. ) -> FutureResult<CollabObjectUpdateByOid, Error>;
  21. fn get_collab_snapshots(
  22. &self,
  23. object_id: &str,
  24. limit: usize,
  25. ) -> FutureResult<Vec<DatabaseSnapshot>, Error>;
  26. }
  27. pub struct DatabaseSnapshot {
  28. pub snapshot_id: i64,
  29. pub database_id: String,
  30. pub data: Vec<u8>,
  31. pub created_at: i64,
  32. }