1extern crate self as icydb;
60
61pub use icydb_build as build;
63pub use icydb_build::build;
64pub use icydb_schema as schema;
65pub use icydb_schema_derive as macros;
66
67#[doc(hidden)]
69pub use icydb_core::{types, value};
70
71#[doc(hidden)]
72pub mod model {
73 pub mod entity {
74 pub use icydb_core::model::EntityModel;
75 }
76
77 pub mod field {
78 pub use icydb_core::model::{FieldKind, FieldModel, RelationStrength};
79 }
80
81 pub mod index {
82 pub use icydb_core::model::IndexModel;
83 }
84
85 pub use entity::EntityModel;
86 pub use field::FieldModel;
87 pub use index::IndexModel;
88}
89
90#[doc(hidden)]
91pub mod obs {
92 pub use icydb_core::obs::{
93 EventReport, MetricsSink, StorageReport, metrics_report, metrics_reset_all, storage_report,
94 };
95}
96
97pub mod patch {
98 pub use icydb_core::patch::{ListPatch, MapPatch, MergePatchError, SetPatch};
99}
100
101pub mod visitor {
102 pub use icydb_core::visitor::{
103 Issue, PathSegment, ScopedContext, VisitorContext, VisitorCore, VisitorError,
104 VisitorIssues, VisitorMutCore, perform_visit, perform_visit_mut,
105 };
106 pub use icydb_core::{sanitize::sanitize, validate::validate};
107}
108
109pub mod base;
111pub mod db;
112pub mod error;
113pub mod traits;
114pub use error::Error;
115
116#[doc(hidden)]
119pub mod __macro {
120 pub use icydb_core::db::{
121 DataStore, Db, EntityRuntimeHooks, IndexStore, StoreRegistry,
122 validate_delete_strong_relations_for_source,
123 };
124 pub use icydb_core::traits::{
125 AsView as CoreAsView, CreateView as CoreCreateView, UpdateView as CoreUpdateView,
126 };
127}
128
129#[doc(hidden)]
136pub mod __reexports {
137 pub use candid;
138 pub use canic_cdk;
139 pub use canic_memory;
140 pub use ctor;
141 pub use derive_more;
142 pub use icydb_derive;
143 pub use num_traits;
144 pub use remain;
145 pub use serde;
146}
147
148pub mod prelude {
154 pub use crate::{
155 db,
156 db::{
157 query,
158 query::{
159 FilterExpr, SortExpr,
160 builder::{
161 FieldRef, count, count_by, exists, first, last, max, max_by, min, min_by, sum,
162 },
163 predicate::Predicate,
164 },
165 },
166 traits::{
167 AsView, Collection as _, Create, CreateView as _, EntityKind as _, EntityValue,
168 Inner as _, MapCollection as _, Path as _, Update, UpdateView as _, View,
169 },
170 types::*,
171 value::Value,
172 };
173 pub use candid::CandidType;
174 pub use serde::{Deserialize, Serialize};
175}
176
177pub mod design {
183 pub mod prelude {
184 pub use ::candid::CandidType;
185 pub use ::derive_more;
186
187 pub use crate::{
188 base, db,
189 db::query::builder::{
190 FieldRef, count, count_by, exists, first, last, max, max_by, min, min_by, sum,
191 },
192 macros::*,
193 traits::{
194 AsView, Collection as _, Create, CreateView, EntityKind, EntityValue as _,
195 FieldValue as _, Inner as _, MapCollection as _, Path as _, Sanitize as _,
196 Sanitizer, Serialize as _, Update, UpdateView, Validate as _, ValidateCustom,
197 Validator, View, Visitable as _,
198 },
199 types::*,
200 value::Value,
201 visitor::VisitorContext,
202 };
203 }
204}
205
206use icydb_core::{
210 error::{ErrorClass, ErrorOrigin, InternalError},
211 traits::Visitable,
212};
213use serde::{Serialize, de::DeserializeOwned};
214
215pub const VERSION: &str = env!("CARGO_PKG_VERSION");
221
222#[macro_export]
228macro_rules! start {
229 () => {
230 include!(concat!(env!("OUT_DIR"), "/actor.rs"));
232 };
233}
234
235#[macro_export]
237#[expect(clippy::crate_in_macro_def)]
238macro_rules! db {
239 () => {
240 crate::db()
241 };
242}
243
244pub fn sanitize(node: &mut dyn Visitable) -> Result<(), Error> {
250 icydb_core::sanitize::sanitize(node)
251 .map_err(InternalError::from)
252 .map_err(Error::from)
253}
254
255pub fn validate(node: &dyn Visitable) -> Result<(), Error> {
257 icydb_core::validate::validate(node)
258 .map_err(InternalError::from)
259 .map_err(Error::from)
260}
261
262pub fn serialize<T>(ty: &T) -> Result<Vec<u8>, Error>
267where
268 T: Serialize,
269{
270 icydb_core::serialize::serialize(ty)
271 .map_err(|err| {
272 InternalError::new(
273 ErrorClass::Internal,
274 ErrorOrigin::Serialize,
275 err.to_string(),
276 )
277 })
278 .map_err(Error::from)
279}
280
281pub fn deserialize<T>(bytes: &[u8]) -> Result<T, Error>
286where
287 T: DeserializeOwned,
288{
289 icydb_core::serialize::deserialize(bytes)
290 .map_err(|err| {
291 InternalError::new(
292 ErrorClass::Internal,
293 ErrorOrigin::Serialize,
294 err.to_string(),
295 )
296 })
297 .map_err(Error::from)
298}