iota_types/
collection_types.rs1use serde::{Deserialize, Serialize};
6
7use crate::{base_types::ObjectID, id::UID};
8
9#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
11pub struct VecMap<K, V> {
12 pub contents: Vec<Entry<K, V>>,
13}
14
15#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
17pub struct Entry<K, V> {
18 pub key: K,
19 pub value: V,
20}
21
22#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
24pub struct VecSet<T> {
25 pub contents: Vec<T>,
26}
27
28#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
30pub struct TableVec {
31 pub contents: Table,
32}
33
34impl Default for TableVec {
35 fn default() -> Self {
36 TableVec {
37 contents: Table {
38 id: ObjectID::ZERO,
39 size: 0,
40 },
41 }
42 }
43}
44
45#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
47pub struct Table {
48 pub id: ObjectID,
49 pub size: u64,
50}
51
52impl Default for Table {
53 fn default() -> Self {
54 Table {
55 id: ObjectID::ZERO,
56 size: 0,
57 }
58 }
59}
60
61#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
63pub struct LinkedTable<K> {
64 pub id: ObjectID,
65 pub size: u64,
66 pub head: Option<K>,
67 pub tail: Option<K>,
68}
69
70impl<K> Default for LinkedTable<K> {
71 fn default() -> Self {
72 LinkedTable {
73 id: ObjectID::ZERO,
74 size: 0,
75 head: None,
76 tail: None,
77 }
78 }
79}
80
81#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
83pub struct LinkedTableNode<K, V> {
84 pub prev: Option<K>,
85 pub next: Option<K>,
86 pub value: V,
87}
88
89#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
91pub struct Bag {
92 pub id: UID,
93 pub size: u64,
94}
95
96impl Default for Bag {
97 fn default() -> Self {
98 Self {
99 id: UID::new(ObjectID::ZERO),
100 size: 0,
101 }
102 }
103}