nest_data_source_api/
data_source.rs

1use crate::api::ApiError;
2use crate::messages::{ActivityRequest, ActivityResponse, ParticipantRequest, ParticipantResponse};
3use async_trait::async_trait;
4
5#[async_trait]
6pub trait DataSource: Send + Sync + 'static {
7    /// Create a new participant in this data source in a specific domain.
8    async fn create_local_participant(
9        &self,
10        request: ParticipantRequest,
11    ) -> Result<Option<ParticipantResponse>, ApiError>;
12
13    /// Update a participant in this data source in a specific domain.
14    async fn update_local_participant(
15        &self,
16        request: ParticipantRequest,
17    ) -> Result<Option<ParticipantResponse>, ApiError>;
18
19    /// Delete a participant from this data source in a specific domain.
20    async fn delete_local_participant(
21        &self,
22        request: ParticipantRequest,
23    ) -> Result<Option<ParticipantResponse>, ApiError>;
24
25    /// Check the details of a participant in this data source in a specific domain.
26    async fn local_participant_details(
27        &self,
28        request: ParticipantRequest,
29    ) -> Result<Option<ParticipantResponse>, ApiError>;
30
31    /// Create an activity for a specific participant.
32    async fn create_participant_activity(
33        &self,
34        request: ActivityRequest,
35    ) -> Result<Option<ActivityResponse>, ApiError>;
36
37    /// Update an activity for a specific participant.
38    async fn update_participant_activity(
39        &self,
40        request: ActivityRequest,
41    ) -> Result<Option<ActivityResponse>, ApiError>;
42
43    /// Delete an activity for a specific participant.
44    async fn delete_participant_activity(
45        &self,
46        request: ActivityRequest,
47    ) -> Result<Option<ActivityResponse>, ApiError>;
48
49    /// Check the details of an activity for a specific participant.
50    /// This should NOT return any sensitive data.
51    async fn participant_activity_details(
52        &self,
53        request: ActivityRequest,
54    ) -> Result<Option<ActivityResponse>, ApiError>;
55
56    /// Check the progress of an activity for a specific participant.
57    /// This should NOT return any sensitive data.
58    async fn participant_activity_progress(
59        &self,
60        request: ActivityRequest,
61    ) -> Result<Option<ActivityResponse>, ApiError>;
62
63    /// Check the result of an activity for a specific participant.
64    /// This should only return how the data can be accessed, not the data itself.
65    /// Or it should return the data, but encrypted for an authorized user.
66    async fn participant_activity_result(
67        &self,
68        request: ActivityRequest,
69    ) -> Result<Option<ActivityResponse>, ApiError>;
70
71    // TODO: same functions for batches of participants
72}