Skip to main content

iota_types/
collection_types.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2024 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5use iota_sdk_types::ObjectId;
6use serde::{Deserialize, Serialize};
7
8use crate::id::UID;
9
10/// Rust version of the Move iota::table::Table type.
11#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
12pub struct TableVec {
13    pub contents: Table,
14}
15
16impl Default for TableVec {
17    fn default() -> Self {
18        TableVec {
19            contents: Table {
20                id: ObjectId::ZERO,
21                size: 0,
22            },
23        }
24    }
25}
26
27/// Rust version of the Move iota::table::Table type.
28#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
29pub struct Table {
30    pub id: ObjectId,
31    pub size: u64,
32}
33
34impl Default for Table {
35    fn default() -> Self {
36        Table {
37            id: ObjectId::ZERO,
38            size: 0,
39        }
40    }
41}
42
43/// Rust version of the Move iota::bag::Bag type.
44#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
45pub struct Bag {
46    pub id: UID,
47    pub size: u64,
48}
49
50impl Default for Bag {
51    fn default() -> Self {
52        Self {
53            id: UID::new(ObjectId::ZERO),
54            size: 0,
55        }
56    }
57}