nest_data_source_api/
data_source.rs

1use crate::api::ApiError;
2use crate::batch_messages::{
3    ActivityBatchRequest, ActivityBatchResponse, ParticipantBatchRequest, ParticipantBatchResponse,
4};
5use crate::messages::{ActivityRequest, ActivityResponse, ParticipantRequest, ParticipantResponse};
6use async_trait::async_trait;
7
8#[async_trait]
9pub trait DataSource: Send + Sync + 'static {
10    /// Create a new participant in this data source in a specific domain.
11    async fn create_local_participant(
12        &self,
13        request: ParticipantRequest,
14    ) -> Result<Option<ParticipantResponse>, ApiError>;
15
16    /// BATCH: Create a new participant in this data source in a specific domain.
17    async fn create_local_participant_batch(
18        &self,
19        request: ParticipantBatchRequest,
20    ) -> Result<Option<ParticipantBatchResponse>, ApiError>;
21
22    /// Update a participant in this data source in a specific domain.
23    async fn update_local_participant(
24        &self,
25        request: ParticipantRequest,
26    ) -> Result<Option<ParticipantResponse>, ApiError>;
27
28    /// BATCH: Update a participant in this data source in a specific domain.
29    async fn update_local_participant_batch(
30        &self,
31        request: ParticipantBatchRequest,
32    ) -> Result<Option<ParticipantBatchResponse>, ApiError>;
33
34    /// Delete a participant from this data source in a specific domain.
35    async fn delete_local_participant(
36        &self,
37        request: ParticipantRequest,
38    ) -> Result<Option<ParticipantResponse>, ApiError>;
39
40    /// BATCH: Delete a participant from this data source in a specific domain.
41    async fn delete_local_participant_batch(
42        &self,
43        request: ParticipantBatchRequest,
44    ) -> Result<Option<ParticipantBatchResponse>, ApiError>;
45
46    /// Check the details of a participant in this data source in a specific domain.
47    async fn local_participant_details(
48        &self,
49        request: ParticipantRequest,
50    ) -> Result<Option<ParticipantResponse>, ApiError>;
51
52    /// BATCH: Check the details of a participant in this data source in a specific domain.
53    async fn local_participant_details_batch(
54        &self,
55        request: ParticipantBatchRequest,
56    ) -> Result<Option<ParticipantBatchResponse>, ApiError>;
57
58    /// Create an activity for a specific participant.
59    async fn create_participant_activity(
60        &self,
61        request: ActivityRequest,
62    ) -> Result<Option<ActivityResponse>, ApiError>;
63
64    /// BATCH: Create an activity for a specific participant.
65    async fn create_participant_activity_batch(
66        &self,
67        request: ActivityBatchRequest,
68    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
69
70    /// Update an activity for a specific participant.
71    async fn update_participant_activity(
72        &self,
73        request: ActivityRequest,
74    ) -> Result<Option<ActivityResponse>, ApiError>;
75
76    /// BATCH: Update an activity for a specific participant.
77    async fn update_participant_activity_batch(
78        &self,
79        request: ActivityBatchRequest,
80    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
81
82    /// Delete an activity for a specific participant.
83    async fn delete_participant_activity(
84        &self,
85        request: ActivityRequest,
86    ) -> Result<Option<ActivityResponse>, ApiError>;
87
88    /// BATCH: Delete an activity for a specific participant.
89    async fn delete_participant_activity_batch(
90        &self,
91        request: ActivityBatchRequest,
92    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
93
94    /// Check the details of an activity for a specific participant.
95    /// This should NOT return any sensitive data.
96    async fn participant_activity_details(
97        &self,
98        request: ActivityRequest,
99    ) -> Result<Option<ActivityResponse>, ApiError>;
100
101    /// BATCH: Check the details of an activity for a specific participant.
102    async fn participant_activity_details_batch(
103        &self,
104        request: ActivityBatchRequest,
105    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
106
107    /// Check the progress of an activity for a specific participant.
108    /// This should NOT return any sensitive data.
109    async fn participant_activity_progress(
110        &self,
111        request: ActivityRequest,
112    ) -> Result<Option<ActivityResponse>, ApiError>;
113
114    /// BATCH: Check the progress of an activity for a specific participant.
115    async fn participant_activity_progress_batch(
116        &self,
117        request: ActivityBatchRequest,
118    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
119
120    /// Check the result of an activity for a specific participant.
121    /// This should only return how the data can be accessed, not the data itself.
122    /// Or it should return the data, but encrypted for an authorized user.
123    async fn participant_activity_result(
124        &self,
125        request: ActivityRequest,
126    ) -> Result<Option<ActivityResponse>, ApiError>;
127
128    /// BATCH: Check the result of an activity for a specific participant.
129    async fn participant_activity_result_batch(
130        &self,
131        request: ActivityBatchRequest,
132    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
133
134    // TODO: Maybe optional implementation for batch that uses the non-batch version
135}