gear_common/storage/primitives/
mod.rs

1// This file is part of Gear.
2
3// Copyright (C) 2022-2025 Gear Technologies Inc.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Gear storage primitives.
20//!
21//! Contains basic behavior of interaction with globally shared data,
22//! which could be used directly for common purposes or be a part of
23//! some consistent logic.
24
25// Private modules declaration.
26mod callback;
27mod counted;
28mod double_map;
29mod iterable;
30mod key;
31mod map;
32mod triple_map;
33mod value;
34
35// Public exports from primitive modules.
36pub use callback::{Callback, EmptyCallback, FallibleCallback, GetCallback, TransposeCallback};
37pub use counted::{Counted, CountedByKey};
38pub use double_map::DoubleMapStorage;
39
40#[cfg(feature = "std")]
41pub use double_map::auxiliary_double_map::*;
42
43pub use iterable::{
44    GetFirstPos, GetSecondPos, GetThirdPos, IterableByKeyMap, IterableMap, IteratorWrap,
45    KeyIterableByKeyMap,
46};
47pub use key::{KeyFor, MailboxKeyGen, QueueKeyGen, WaitlistKeyGen};
48pub use map::{AppendMapStorage, MapStorage};
49pub use triple_map::TripleMapStorage;
50pub use value::ValueStorage;
51
52use sp_runtime::{
53    codec::{self, Decode, Encode, MaxEncodedLen},
54    scale_info::{self, TypeInfo},
55};
56
57/// Type for interval values: e.g. in time `(since, till)`.
58#[derive(Clone, Debug, Decode, Encode, MaxEncodedLen, PartialEq, Eq, PartialOrd, Ord, TypeInfo)]
59#[codec(crate = codec)]
60#[scale_info(crate = scale_info)]
61pub struct Interval<T> {
62    pub start: T,
63    pub finish: T,
64}