iqengine_plugin/server/
function_post_response.rs

1use super::SamplesB64;
2
3#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
4pub struct FunctionPostResponse {
5    #[serde(rename = "data_output", skip_serializing_if = "Option::is_none")]
6    pub data_output: Option<Vec<crate::server::SamplesB64>>,
7    // #[serde(rename = "samples_cloud", skip_serializing_if = "Option::is_none")]
8    // pub samples_cloud: Option<Vec<crate::server::SamplesCloud>>,
9    /// See https://github.com/sigmf/SigMF/blob/sigmf-v1.x/sigmf-spec.md#annotations-array
10    #[serde(rename = "annotations", skip_serializing_if = "Option::is_none")]
11    pub annotations: Option<Vec<crate::server::Annotation>>,
12    #[serde(rename = "details", skip_serializing_if = "Option::is_none")]
13    pub details: Option<String>,
14}
15
16impl FunctionPostResponse {
17    pub fn new() -> FunctionPostResponse {
18        FunctionPostResponse {
19            data_output: None,
20            annotations: None,
21            details: None,
22        }
23    }
24}
25
26impl Default for FunctionPostResponse {
27    fn default() -> Self {
28        Self::new()
29    }
30}
31
32pub struct FunctionPostResponseBuilder {
33    resp: FunctionPostResponse,
34}
35
36impl Default for FunctionPostResponseBuilder {
37    fn default() -> Self {
38        Self::new()
39    }
40}
41
42impl FunctionPostResponseBuilder {
43    pub fn new() -> FunctionPostResponseBuilder {
44        FunctionPostResponseBuilder {
45            resp: FunctionPostResponse::new(),
46        }
47    }
48
49    pub fn details(mut self, failure: impl Into<String>) -> FunctionPostResponseBuilder {
50        self.resp.details = Some(failure.into());
51        self
52    }
53
54    pub fn with_samples_b64(mut self, samples: SamplesB64) -> FunctionPostResponseBuilder {
55        self.resp.data_output = Some(vec![samples]);
56        self
57    }
58
59    pub fn build(self) -> FunctionPostResponse {
60        self.resp
61    }
62}