Skip to main content

aleph_types/message/
item_type.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "lowercase")]
5pub enum ItemType {
6    Inline,
7    Storage,
8    Ipfs,
9}
10
11#[cfg(test)]
12mod tests {
13    use super::*;
14
15    #[test]
16    fn test_item_type_serialization() {
17        assert_eq!(
18            serde_json::to_string(&ItemType::Inline).unwrap(),
19            "\"inline\""
20        );
21        assert_eq!(
22            serde_json::to_string(&ItemType::Storage).unwrap(),
23            "\"storage\""
24        );
25        assert_eq!(serde_json::to_string(&ItemType::Ipfs).unwrap(), "\"ipfs\"");
26    }
27
28    #[test]
29    fn test_item_type_deserialization() {
30        assert_eq!(
31            serde_json::from_str::<ItemType>("\"inline\"").unwrap(),
32            ItemType::Inline
33        );
34        assert_eq!(
35            serde_json::from_str::<ItemType>("\"storage\"").unwrap(),
36            ItemType::Storage
37        );
38        assert_eq!(
39            serde_json::from_str::<ItemType>("\"ipfs\"").unwrap(),
40            ItemType::Ipfs
41        );
42    }
43}