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