Skip to main content

calimero_storage/
lib.rs

1//! Storage interface providing functionality for interacting with stored data.
2//!
3//! This module provides the primary interface for interacting with the storage
4//! system, as a layer on top of the underlying database store.
5//!
6
7#![forbid(unreachable_pub, unsafe_op_in_unsafe_fn)]
8#![deny(
9    unsafe_code,
10    clippy::expect_used,
11    clippy::missing_errors_doc,
12    clippy::panic,
13    clippy::unwrap_in_result,
14    clippy::unwrap_used
15)]
16#![warn(
17    missing_docs,
18    clippy::future_not_send,
19    clippy::let_underscore_untyped,
20    clippy::map_err_ignore,
21    clippy::pattern_type_mismatch,
22    clippy::same_name_method,
23    clippy::shadow_reuse,
24    clippy::shadow_same,
25    clippy::shadow_unrelated,
26    clippy::unreachable,
27    clippy::use_debug
28)]
29//	Lints specifically disabled for unit tests
30#![cfg_attr(
31    test,
32    allow(
33        non_snake_case,
34        clippy::arithmetic_side_effects,
35        clippy::assigning_clones,
36        clippy::cast_lossless,
37        clippy::cast_possible_truncation,
38        clippy::cast_precision_loss,
39        clippy::cognitive_complexity,
40        clippy::default_numeric_fallback,
41        clippy::exhaustive_enums,
42        clippy::exhaustive_structs,
43        clippy::expect_used,
44        clippy::indexing_slicing,
45        clippy::let_underscore_must_use,
46        clippy::let_underscore_untyped,
47        clippy::missing_assert_message,
48        clippy::missing_panics_doc,
49        clippy::must_use_candidate,
50        clippy::panic,
51        clippy::print_stdout,
52        clippy::too_many_lines,
53        clippy::unwrap_in_result,
54        clippy::unwrap_used,
55        reason = "Not useful in unit tests"
56    )
57)]
58
59pub mod action;
60pub mod address;
61pub mod collections;
62pub mod constants;
63pub mod delta;
64pub mod entities;
65pub mod env;
66pub mod error;
67pub mod index;
68pub mod integration;
69pub mod interface;
70pub mod js;
71pub mod logical_clock;
72pub mod merge;
73pub mod snapshot;
74pub mod store;
75
76// Re-export for convenience
77pub use merge::register_crdt_merge;
78
79/// Re-exported types, mostly for use in macros (for convenience).
80pub mod exports {
81    pub use sha2::{Digest, Sha256};
82}
83
84/// Re-export the storage macros
85pub use calimero_storage_macros::{AtomicUnit, Collection};
86
87// Re-export commonly used types
88pub use entities::{Data, Element};
89pub use error::StorageError;
90pub use interface::Interface;
91
92/// Shared test functionality.
93#[cfg(test)]
94pub mod tests {
95    /// CRDT collections (UnorderedMap, Vector, Counter) tests.
96    pub mod collections;
97    /// Common test utilities and data structures.
98    pub mod common;
99    /// Comprehensive CRDT behavior tests.
100    pub mod crdt;
101    /// Delta creation and commit tests.
102    pub mod delta;
103    /// LWW (Last-Write-Wins) Register CRDT tests.
104    pub mod lww_register;
105    /// CRDT type-based merge dispatch tests (TDD for PR #1889).
106    pub mod merge_dispatch;
107    /// Merge integration tests (using serialization instead of Clone).
108    pub mod merge_integration;
109    /// Merkle hash propagation tests.
110    pub mod merkle;
111    /// RGA (Replicated Growable Array) CRDT tests.
112    pub mod rga;
113    // TODO: Re-enable once Clone is implemented for collections
114    // /// Nested CRDT merge behavior tests.
115    // pub mod nested_crdt_merge;
116}
117
118#[cfg(test)]
119mod doc_tests_package_usage {
120    use calimero_sdk as _;
121}