azure_functions/send_grid/
content.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents the content of an email message.
4///
5/// You can include multiple mime types of content, but you must specify at least one.
6#[derive(Debug, Default, Clone, Serialize, Deserialize)]
7pub struct Content {
8    /// The mime type of the content you are including in your email (e.g. "text/plain" or "text/html").
9    #[serde(rename = "type")]
10    pub mime_type: String,
11    /// The actual content of the specified mime type for the email message.
12    pub value: String,
13}
14
15#[cfg(test)]
16mod tests {
17    use super::*;
18    use serde_json::to_string;
19
20    #[test]
21    fn it_serializes_to_json() {
22        let json = to_string(&Content {
23            mime_type: "text/plain".to_owned(),
24            value: "hello world".to_owned(),
25        })
26        .unwrap();
27
28        assert_eq!(json, r#"{"type":"text/plain","value":"hello world"}"#);
29    }
30}