jmap_client/sieve/
validate.rs

1use serde::{Deserialize, Serialize};
2
3use crate::core::{set::SetError, RequestParams};
4
5#[derive(Debug, Clone, Serialize)]
6pub struct SieveScriptValidateRequest {
7    #[serde(rename = "accountId")]
8    account_id: String,
9
10    #[serde(rename = "blobId")]
11    blob_id: String,
12}
13
14#[derive(Debug, Deserialize)]
15#[allow(dead_code)]
16pub struct SieveScriptValidateResponse {
17    #[serde(rename = "accountId")]
18    account_id: String,
19
20    error: Option<SetError<String>>,
21}
22
23impl SieveScriptValidateRequest {
24    pub fn new(params: RequestParams, blob_id: impl Into<String>) -> Self {
25        SieveScriptValidateRequest {
26            account_id: params.account_id,
27            blob_id: blob_id.into(),
28        }
29    }
30}
31
32impl SieveScriptValidateResponse {
33    pub fn unwrap_error(self) -> crate::Result<()> {
34        match self.error {
35            Some(err) => Err(err.into()),
36            None => Ok(()),
37        }
38    }
39}