1#![warn(unreachable_pub)]
9#![cfg_attr(all(test, not(feature = "sql")), allow(dead_code))]
13
14extern crate self as icydb;
15
16#[macro_use]
17pub(crate) mod scalar_registry;
18
19pub mod db;
21pub mod error;
22pub mod metrics;
23pub mod model;
24pub(crate) mod runtime;
25pub mod sanitize;
26pub mod traits;
27pub mod types;
28pub mod validate;
29pub mod value;
30pub mod visitor;
31
32#[cfg(test)]
34pub(crate) mod testing;
35
36pub const MAX_INDEX_FIELDS: usize = 4;
45
46pub mod prelude {
54 pub use crate::{
55 model::{entity::EntityModel, index::IndexModel},
56 traits::{EntityKind, Path},
57 value::{InputValue, OutputValue},
58 };
59}
60
61#[doc(hidden)]
66pub mod __macro {
67 #[doc(hidden)]
68 pub fn decode_generated_runtime_field_value<T>(
69 value: &crate::value::Value,
70 context: Option<&dyn crate::value::RuntimeEnumContext>,
71 field_name: &'static str,
72 ) -> Result<T, crate::error::InternalError>
73 where
74 T: crate::value::RuntimeValueDecode,
75 {
76 crate::value::runtime_value_from_value_with_optional_enum_context(value, context)
77 .ok_or_else(|| {
78 crate::error::InternalError::persisted_row_field_decode_failed(field_name, ())
79 })
80 }
81
82 pub use crate::db::{
83 CompositePrimaryKeyValue, CompositePrimaryKeyValueError, EntityKeyBytes,
84 EntityKeyBytesError, GeneratedStructuralMapPayloadSlices, JournalTailStore, KeyValueCodec,
85 PersistedRow, PersistedScalar, PrimaryKeyComponent, PrimaryKeyDecode, PrimaryKeyEncode,
86 PrimaryKeyEncodeError, PrimaryKeyValue, ScalarRelationTargetKey,
87 ScalarRelationTargetKeyMatchesDeclaredPrimitive, ScalarSlotValueRef, ScalarValueRef,
88 SlotReader, StoreRuntimeStorageCapabilities, validate_entity_key_bytes_buffer,
89 };
90 pub use crate::error::{ErrorClass, ErrorOrigin, InternalError};
91 pub use crate::traits::{
92 AuthoredFieldProjection, FieldProjection, PersistedByKindCodec,
93 PersistedStructuredFieldCodec,
94 };
95 pub use crate::value::{
96 InputValue, InputValueEnum, RuntimeEnumContext, RuntimeEnumSelection, RuntimeValueDecode,
97 RuntimeValueEncode, RuntimeValueKind, RuntimeValueMeta, Value, ValueEnum,
98 runtime_value_btree_map_from_value, runtime_value_btree_set_from_value,
99 runtime_value_collection_to_value, runtime_value_from_value,
100 runtime_value_from_value_with_enum_context,
101 runtime_value_from_value_with_optional_enum_context, runtime_value_from_vec_into,
102 runtime_value_from_vec_into_btree_map, runtime_value_from_vec_into_btree_set,
103 runtime_value_into, runtime_value_map_collection_to_value, runtime_value_to_value,
104 runtime_value_vec_from_value,
105 };
106 pub use ic_memory::{
107 bootstrap_default_memory_manager, ic_memory_declaration, ic_memory_key, ic_memory_range,
108 };
109
110 #[doc(hidden)]
111 #[must_use]
112 pub fn encode_generated_structural_text_payload_bytes(value: &str) -> Vec<u8> {
113 crate::db::encode_generated_structural_text_payload_bytes(value)
114 }
115
116 #[doc(hidden)]
117 #[must_use]
118 pub fn encode_generated_structural_list_payload_bytes(items: &[&[u8]]) -> Vec<u8> {
119 crate::db::encode_generated_structural_list_payload_bytes(items)
120 }
121
122 #[doc(hidden)]
123 #[must_use]
124 pub fn encode_generated_structural_map_payload_bytes(entries: &[(&[u8], &[u8])]) -> Vec<u8> {
125 crate::db::encode_generated_structural_map_payload_bytes(entries)
126 }
127
128 #[doc(hidden)]
129 pub fn decode_generated_structural_text_payload_bytes(
130 raw_bytes: &[u8],
131 ) -> Result<String, crate::error::InternalError> {
132 crate::db::decode_generated_structural_text_payload_bytes(raw_bytes)
133 }
134
135 #[doc(hidden)]
136 pub fn decode_generated_structural_list_payload_bytes(
137 raw_bytes: &[u8],
138 ) -> Result<Vec<&[u8]>, crate::error::InternalError> {
139 crate::db::decode_generated_structural_list_payload_bytes(raw_bytes)
140 }
141
142 #[doc(hidden)]
143 pub fn decode_generated_structural_map_payload_bytes(
144 raw_bytes: &[u8],
145 ) -> Result<crate::db::GeneratedStructuralMapPayloadSlices<'_>, crate::error::InternalError>
146 {
147 crate::db::decode_generated_structural_map_payload_bytes(raw_bytes)
148 }
149
150 #[doc(hidden)]
151 pub fn generated_persisted_structured_payload_decode_failed(
152 detail: impl std::fmt::Display,
153 ) -> crate::error::InternalError {
154 crate::db::generated_persisted_structured_payload_decode_failed(detail)
155 }
156
157 #[doc(hidden)]
158 pub fn encode_non_enum_protocol_value_bytes(
159 value: &crate::value::Value,
160 ) -> Result<Vec<u8>, crate::error::InternalError> {
161 crate::db::encode_non_enum_protocol_value_bytes(value)
162 }
163
164 #[doc(hidden)]
165 pub fn decode_non_enum_protocol_value_bytes(
166 raw_bytes: &[u8],
167 ) -> Result<crate::value::Value, crate::error::InternalError> {
168 crate::db::decode_non_enum_protocol_value_bytes(raw_bytes)
169 }
170
171 #[doc(hidden)]
172 pub fn encode_persisted_structured_many_slot_payload<T>(
173 value: &[T],
174 field_name: &'static str,
175 ) -> Result<Vec<u8>, crate::error::InternalError>
176 where
177 T: crate::traits::PersistedStructuredFieldCodec,
178 {
179 crate::db::encode_persisted_structured_many_slot_payload(value, field_name)
180 }
181
182 #[doc(hidden)]
183 pub fn decode_persisted_structured_many_slot_payload<T>(
184 bytes: &[u8],
185 field_name: &'static str,
186 ) -> Result<Vec<T>, crate::error::InternalError>
187 where
188 T: crate::traits::PersistedStructuredFieldCodec,
189 {
190 crate::db::decode_persisted_structured_many_slot_payload(bytes, field_name)
191 }
192
193 #[doc(hidden)]
194 pub fn encode_persisted_structured_slot_payload<T>(
195 value: &T,
196 field_name: &'static str,
197 ) -> Result<Vec<u8>, crate::error::InternalError>
198 where
199 T: crate::traits::PersistedStructuredFieldCodec,
200 {
201 crate::db::encode_persisted_structured_slot_payload(value, field_name)
202 }
203
204 #[doc(hidden)]
205 pub fn decode_persisted_structured_slot_payload<T>(
206 bytes: &[u8],
207 field_name: &'static str,
208 ) -> Result<T, crate::error::InternalError>
209 where
210 T: crate::traits::PersistedStructuredFieldCodec,
211 {
212 crate::db::decode_persisted_structured_slot_payload(bytes, field_name)
213 }
214
215 #[doc(hidden)]
216 pub fn encode_persisted_option_scalar_slot_payload<T>(
217 value: &Option<T>,
218 field_name: &'static str,
219 ) -> Result<Vec<u8>, crate::error::InternalError>
220 where
221 T: PersistedScalar,
222 {
223 crate::db::encode_persisted_option_scalar_slot_payload(value, field_name)
224 }
225
226 #[doc(hidden)]
227 pub fn decode_persisted_option_scalar_slot_payload<T>(
228 bytes: &[u8],
229 field_name: &'static str,
230 ) -> Result<Option<T>, crate::error::InternalError>
231 where
232 T: PersistedScalar,
233 {
234 crate::db::decode_persisted_option_scalar_slot_payload(bytes, field_name)
235 }
236
237 #[doc(hidden)]
238 pub fn encode_persisted_scalar_slot_payload<T>(
239 value: &T,
240 field_name: &'static str,
241 ) -> Result<Vec<u8>, crate::error::InternalError>
242 where
243 T: PersistedScalar,
244 {
245 crate::db::encode_persisted_scalar_slot_payload(value, field_name)
246 }
247
248 #[doc(hidden)]
249 pub fn decode_persisted_scalar_slot_payload<T>(
250 bytes: &[u8],
251 field_name: &'static str,
252 ) -> Result<T, crate::error::InternalError>
253 where
254 T: PersistedScalar,
255 {
256 crate::db::decode_persisted_scalar_slot_payload(bytes, field_name)
257 }
258
259 #[doc(hidden)]
260 pub fn encode_persisted_slot_payload_by_kind<T>(
261 value: &T,
262 kind: crate::model::field::FieldKind,
263 field_name: &'static str,
264 ) -> Result<Vec<u8>, crate::error::InternalError>
265 where
266 T: crate::traits::PersistedByKindCodec,
267 {
268 crate::db::encode_persisted_slot_payload_by_kind(value, kind, field_name)
269 }
270
271 #[doc(hidden)]
272 pub fn decode_persisted_slot_payload_by_kind<T>(
273 bytes: &[u8],
274 kind: crate::model::field::FieldKind,
275 field_name: &'static str,
276 ) -> Result<T, crate::error::InternalError>
277 where
278 T: crate::traits::PersistedByKindCodec,
279 {
280 crate::db::decode_persisted_slot_payload_by_kind(bytes, kind, field_name)
281 }
282
283 #[doc(hidden)]
284 pub fn decode_persisted_option_slot_payload_by_kind<T>(
285 bytes: &[u8],
286 kind: crate::model::field::FieldKind,
287 field_name: &'static str,
288 ) -> Result<Option<T>, crate::error::InternalError>
289 where
290 T: crate::traits::PersistedByKindCodec,
291 {
292 crate::db::decode_persisted_option_slot_payload_by_kind(bytes, kind, field_name)
293 }
294}