thrift_codec/data/
list.rs1use crate::data::{Elements, Map, Set, Struct};
2use std::ops::Deref;
3
4use super::Uuid;
5
6#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(Serialize))]
9pub struct List {
10 elements: Elements,
11}
12impl List {
13 pub fn new(elements: Elements) -> Self {
15 List { elements }
16 }
17}
18impl Deref for List {
19 type Target = Elements;
20 fn deref(&self) -> &Self::Target {
21 &self.elements
22 }
23}
24impl From<Vec<bool>> for List {
25 fn from(f: Vec<bool>) -> Self {
26 List::new(Elements::Bool(f))
27 }
28}
29impl From<Vec<i8>> for List {
30 fn from(f: Vec<i8>) -> Self {
31 List::new(Elements::I8(f))
32 }
33}
34impl From<Vec<i16>> for List {
35 fn from(f: Vec<i16>) -> Self {
36 List::new(Elements::I16(f))
37 }
38}
39impl From<Vec<i32>> for List {
40 fn from(f: Vec<i32>) -> Self {
41 List::new(Elements::I32(f))
42 }
43}
44impl From<Vec<i64>> for List {
45 fn from(f: Vec<i64>) -> Self {
46 List::new(Elements::I64(f))
47 }
48}
49impl From<Vec<f64>> for List {
50 fn from(f: Vec<f64>) -> Self {
51 List::new(Elements::Double(f))
52 }
53}
54impl From<Vec<Vec<u8>>> for List {
55 fn from(f: Vec<Vec<u8>>) -> Self {
56 List::new(Elements::Binary(f))
57 }
58}
59impl From<Vec<Struct>> for List {
60 fn from(f: Vec<Struct>) -> Self {
61 List::new(Elements::Struct(f))
62 }
63}
64impl From<Vec<Map>> for List {
65 fn from(f: Vec<Map>) -> Self {
66 List::new(Elements::Map(f))
67 }
68}
69impl From<Vec<Set>> for List {
70 fn from(f: Vec<Set>) -> Self {
71 List::new(Elements::Set(f))
72 }
73}
74impl From<Vec<List>> for List {
75 fn from(f: Vec<List>) -> Self {
76 List::new(Elements::List(f))
77 }
78}
79impl From<Vec<Uuid>> for List {
80 fn from(f: Vec<Uuid>) -> Self {
81 List::new(Elements::Uuid(f))
82 }
83}