Skip to content

Commit

Permalink
Add trait for snapshot data
Browse files Browse the repository at this point in the history
  • Loading branch information
kasugamirai committed Oct 4, 2024
1 parent 332f84c commit 9dc5020
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 12 additions & 1 deletion websocket/crates/domain/src/repository.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::project::ProjectEditingSession;
use crate::project::{ProjectEditingSession, SnapshotData};
use crate::projection::Project;
use crate::types::snapshot::ProjectSnapshot;
use std::error::Error;
Expand Down Expand Up @@ -35,3 +35,14 @@ pub trait ProjectSnapshotRepository {
async fn get_latest_snapshot_state(&self, project_id: &str) -> Result<Vec<u8>, Self::Error>;
async fn update_snapshot(&self, snapshot: ProjectSnapshot) -> Result<(), Self::Error>;
}

#[async_trait::async_trait]
pub trait SnapshotDataRepository {
type Error;

async fn create_snapshot_data(&self, snapshot_data: SnapshotData) -> Result<(), Self::Error>;
async fn get_snapshot_data(
&self,
project_id: &str,
) -> Result<Option<SnapshotData>, Self::Error>;
}
10 changes: 7 additions & 3 deletions websocket/crates/domain/src/types/data.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use serde::{Deserialize, Serialize};

use super::snapshot::SnapshotInfo;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SnapshotData {
pub project_id: String,
pub name: Option<String>,
pub created_by: Option<String>,
pub info: SnapshotInfo,
pub state: Vec<u8>,
}
1 change: 1 addition & 0 deletions websocket/crates/domain/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod data;
pub mod projection;
pub mod snapshot;
pub mod user;

0 comments on commit 9dc5020

Please sign in to comment.