nest_data_source_api/
data_source.rs

1use crate::api::ApiError;
2use crate::batch_messages::{ActivityBatchRequest, ActivityBatchResponse};
3use crate::messages::{ActivityRequest, ActivityResponse};
4use async_trait::async_trait;
5
6#[async_trait]
7pub trait DataSource: Send + Sync + 'static {
8    /// Create an activity for a specific participant.
9    async fn create_participant_activity(
10        &self,
11        request: ActivityRequest,
12    ) -> Result<Option<ActivityResponse>, ApiError>;
13
14    /// BATCH: Create an activity for a specific participant.
15    async fn create_participant_activity_batch(
16        &self,
17        request: ActivityBatchRequest,
18    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
19
20    /// Update an activity for a specific participant.
21    async fn update_participant_activity(
22        &self,
23        request: ActivityRequest,
24    ) -> Result<Option<ActivityResponse>, ApiError>;
25
26    /// BATCH: Update an activity for a specific participant.
27    async fn update_participant_activity_batch(
28        &self,
29        request: ActivityBatchRequest,
30    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
31
32    /// Delete an activity for a specific participant.
33    async fn delete_participant_activity(
34        &self,
35        request: ActivityRequest,
36    ) -> Result<Option<ActivityResponse>, ApiError>;
37
38    /// BATCH: Delete an activity for a specific participant.
39    async fn delete_participant_activity_batch(
40        &self,
41        request: ActivityBatchRequest,
42    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
43
44    /// Check the details of an activity for a specific participant.
45    /// This should NOT return any sensitive data.
46    async fn participant_activity_details(
47        &self,
48        request: ActivityRequest,
49    ) -> Result<Option<ActivityResponse>, ApiError>;
50
51    /// BATCH: Check the details of an activity for a specific participant.
52    async fn participant_activity_details_batch(
53        &self,
54        request: ActivityBatchRequest,
55    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
56
57    /// Check the progress of an activity for a specific participant.
58    /// This should NOT return any sensitive data.
59    async fn participant_activity_progress(
60        &self,
61        request: ActivityRequest,
62    ) -> Result<Option<ActivityResponse>, ApiError>;
63
64    /// BATCH: Check the progress of an activity for a specific participant.
65    async fn participant_activity_progress_batch(
66        &self,
67        request: ActivityBatchRequest,
68    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
69
70    /// Check the result of an activity for a specific participant.
71    /// This should only return how the data can be accessed, not the data itself.
72    /// Or it should return the data, but encrypted for an authorized user.
73    async fn participant_activity_result(
74        &self,
75        request: ActivityRequest,
76    ) -> Result<Option<ActivityResponse>, ApiError>;
77
78    /// BATCH: Check the result of an activity for a specific participant.
79    async fn participant_activity_result_batch(
80        &self,
81        request: ActivityBatchRequest,
82    ) -> Result<Option<ActivityBatchResponse>, ApiError>;
83
84    // TODO: Maybe optional implementation for batch that uses the non-batch version
85}