xref: /xiu/protocol/rtmp/src/amf0/define.rs (revision c8d4d932)
1 use indexmap::IndexMap;
2 
3 #[derive(PartialEq, Clone, Debug)]
4 pub enum Amf0ValueType {
5     Number(f64),
6     Boolean(bool),
7     UTF8String(String),
8     Object(IndexMap<String, Amf0ValueType>),
9     Null,
10     EcmaArray(IndexMap<String, Amf0ValueType>),
11     LongUTF8String(String),
12     END,
13 }
14 
15 // pub struct Amf0Object {
16 //     pub key: String,
17 //     pub value: Amf0ValueType,
18 // }
19 
20 // impl Amf0Object {
21 //     pub fn clone(self) -> Amf0Object {
22 //         Amf0Object {
23 //             key: self.key.clone(),
24 //             value: self.value.clone(),
25 //         }
26 //     }
27 // }
28 
29 // pub struct AmfObjectMap{
30 //     properties: HashMap<String,Amf0Object>,
31 
32 // }
33 
34 // impl AmfObjectMap {
35 //     fn Clone(self) -> AmfObjectMap {
36 //        self.properties.clone()
37 //     }
38 // }
39 
40 // pub struct UnOrderedMap {
41 //     properties: Vec<Amf0Object>,
42 // }
43 
44 // impl UnOrderedMap {
45 //     pub fn new() -> UnOrderedMap {
46 //         UnOrderedMap {
47 //             properties: Vec::new(),
48 //         }
49 //     }
50 //     pub fn insert(self, key: String, val: Amf0ValueType) -> Option<Amf0ValueType> {
51 //         for i in &self.properties {
52 //             if i.key == key {
53 //                 let tmpVal = i.value.clone();
54 //                 i.value = val;
55 //                 return Some(tmpVal);
56 //             }
57 //         }
58 
59 //         let obj = Amf0Object {
60 //             key: key,
61 //             value: val,
62 //         };
63 //         self.properties.push(obj);
64 
65 //         None
66 //     }
67 //     fn get_by_key(self, key: String) -> Option<Amf0ValueType> {
68 //         for i in self.properties {
69 //             if i.key == key {
70 //                 return Some(i.value);
71 //             }
72 //         }
73 //         None
74 //     }
75 
76 //     pub fn get(self, idx: usize) -> Amf0Object {
77 //         self.properties[idx]
78 //     }
79 
80 //     pub fn len(self) -> usize {
81 //         self.properties.len()
82 //     }
83 
84 //     pub fn Clone(self) -> UnOrderedMap {
85 //         UnOrderedMap {
86 //             properties: self.properties.clone(),
87 //         }
88 //     }
89 // }
90