#![warn(unreachable_pub)]
#![cfg_attr(all(test, not(feature = "sql")), allow(dead_code))]
extern crate self as icydb;
#[macro_use]
pub(crate) mod scalar_registry;
pub mod db;
pub mod error;
pub mod metrics;
pub mod model;
pub(crate) mod runtime;
pub mod sanitize;
pub mod traits;
pub mod types;
pub mod validate;
pub mod value;
pub mod visitor;
#[cfg(test)]
pub(crate) mod testing;
pub const MAX_INDEX_FIELDS: usize = 4;
pub mod prelude {
pub use crate::{
model::{entity::EntityModel, index::IndexModel},
traits::{EntityKind, Path},
value::{InputValue, OutputValue},
};
}
#[doc(hidden)]
pub mod __macro {
#[doc(hidden)]
pub fn decode_generated_runtime_field_value<T>(
value: &crate::value::Value,
context: Option<&dyn crate::traits::RuntimeEnumContext>,
field_name: &'static str,
) -> Result<T, crate::error::InternalError>
where
T: crate::traits::RuntimeValueDecode,
{
crate::traits::runtime_value_from_value_with_optional_enum_context(value, context)
.ok_or_else(|| {
crate::error::InternalError::persisted_row_field_decode_failed(field_name, ())
})
}
pub use crate::db::{
CompositePrimaryKeyValue, CompositePrimaryKeyValueError,
GeneratedStructuralMapPayloadSlices, JournalTailStore, PersistedRow, PersistedScalar,
PrimaryKeyComponent, PrimaryKeyValue, ScalarSlotValueRef, ScalarValueRef, SlotReader,
SlotWriter, StoreRuntimeStorageCapabilities,
};
pub use crate::error::{ErrorClass, ErrorOrigin, InternalError};
pub use crate::traits::{
AuthoredFieldProjection, EntityKeyBytes, FieldProjection, KeyValueCodec,
PersistedByKindCodec, PersistedFieldMetaCodec, PersistedFieldSlotCodec,
PersistedStructuredFieldCodec, PrimaryKeyCodec, PrimaryKeyDecode, PrimaryKeyEncodeError,
RuntimeEnumContext, RuntimeEnumSelection, RuntimeValueDecode, RuntimeValueEncode,
RuntimeValueKind, RuntimeValueMeta, ScalarRelationTargetKey,
ScalarRelationTargetKeyMatchesDeclaredPrimitive, runtime_value_btree_map_from_value,
runtime_value_btree_set_from_value, runtime_value_collection_to_value,
runtime_value_from_value, runtime_value_from_value_with_enum_context,
runtime_value_from_value_with_optional_enum_context, runtime_value_from_vec_into,
runtime_value_from_vec_into_btree_map, runtime_value_from_vec_into_btree_set,
runtime_value_into, runtime_value_map_collection_to_value, runtime_value_to_value,
runtime_value_vec_from_value,
};
pub use crate::value::{InputValue, InputValueEnum, Value, ValueEnum};
pub use ic_memory::{
bootstrap_default_memory_manager, ic_memory_declaration, ic_memory_key, ic_memory_range,
};
#[doc(hidden)]
#[must_use]
pub fn encode_generated_structural_text_payload_bytes(value: &str) -> Vec<u8> {
crate::db::encode_generated_structural_text_payload_bytes(value)
}
#[doc(hidden)]
#[must_use]
pub fn encode_generated_structural_list_payload_bytes(items: &[&[u8]]) -> Vec<u8> {
crate::db::encode_generated_structural_list_payload_bytes(items)
}
#[doc(hidden)]
#[must_use]
pub fn encode_generated_structural_map_payload_bytes(entries: &[(&[u8], &[u8])]) -> Vec<u8> {
crate::db::encode_generated_structural_map_payload_bytes(entries)
}
#[doc(hidden)]
pub fn decode_generated_structural_text_payload_bytes(
raw_bytes: &[u8],
) -> Result<String, crate::error::InternalError> {
crate::db::decode_generated_structural_text_payload_bytes(raw_bytes)
}
#[doc(hidden)]
pub fn decode_generated_structural_list_payload_bytes(
raw_bytes: &[u8],
) -> Result<Vec<&[u8]>, crate::error::InternalError> {
crate::db::decode_generated_structural_list_payload_bytes(raw_bytes)
}
#[doc(hidden)]
pub fn decode_generated_structural_map_payload_bytes(
raw_bytes: &[u8],
) -> Result<crate::db::GeneratedStructuralMapPayloadSlices<'_>, crate::error::InternalError>
{
crate::db::decode_generated_structural_map_payload_bytes(raw_bytes)
}
#[doc(hidden)]
pub fn generated_persisted_structured_payload_decode_failed(
detail: impl std::fmt::Display,
) -> crate::error::InternalError {
crate::db::generated_persisted_structured_payload_decode_failed(detail)
}
#[doc(hidden)]
pub fn encode_non_enum_protocol_value_bytes(
value: &crate::value::Value,
) -> Result<Vec<u8>, crate::error::InternalError> {
crate::db::encode_non_enum_protocol_value_bytes(value)
}
#[doc(hidden)]
pub fn decode_non_enum_protocol_value_bytes(
raw_bytes: &[u8],
) -> Result<crate::value::Value, crate::error::InternalError> {
crate::db::decode_non_enum_protocol_value_bytes(raw_bytes)
}
#[doc(hidden)]
pub fn encode_persisted_structured_many_slot_payload<T>(
value: &[T],
field_name: &'static str,
) -> Result<Vec<u8>, crate::error::InternalError>
where
T: crate::traits::PersistedStructuredFieldCodec,
{
crate::db::encode_persisted_structured_many_slot_payload(value, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_structured_many_slot_payload<T>(
bytes: &[u8],
field_name: &'static str,
) -> Result<Vec<T>, crate::error::InternalError>
where
T: crate::traits::PersistedStructuredFieldCodec,
{
crate::db::decode_persisted_structured_many_slot_payload(bytes, field_name)
}
#[doc(hidden)]
pub fn encode_persisted_structured_slot_payload<T>(
value: &T,
field_name: &'static str,
) -> Result<Vec<u8>, crate::error::InternalError>
where
T: crate::traits::PersistedStructuredFieldCodec,
{
crate::db::encode_persisted_structured_slot_payload(value, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_structured_slot_payload<T>(
bytes: &[u8],
field_name: &'static str,
) -> Result<T, crate::error::InternalError>
where
T: crate::traits::PersistedStructuredFieldCodec,
{
crate::db::decode_persisted_structured_slot_payload(bytes, field_name)
}
#[doc(hidden)]
pub fn encode_persisted_option_scalar_slot_payload<T>(
value: &Option<T>,
field_name: &'static str,
) -> Result<Vec<u8>, crate::error::InternalError>
where
T: PersistedScalar,
{
crate::db::encode_persisted_option_scalar_slot_payload(value, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_option_scalar_slot_payload<T>(
bytes: &[u8],
field_name: &'static str,
) -> Result<Option<T>, crate::error::InternalError>
where
T: PersistedScalar,
{
crate::db::decode_persisted_option_scalar_slot_payload(bytes, field_name)
}
#[doc(hidden)]
pub fn encode_persisted_scalar_slot_payload<T>(
value: &T,
field_name: &'static str,
) -> Result<Vec<u8>, crate::error::InternalError>
where
T: PersistedScalar,
{
crate::db::encode_persisted_scalar_slot_payload(value, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_scalar_slot_payload<T>(
bytes: &[u8],
field_name: &'static str,
) -> Result<T, crate::error::InternalError>
where
T: PersistedScalar,
{
crate::db::decode_persisted_scalar_slot_payload(bytes, field_name)
}
#[doc(hidden)]
pub fn encode_persisted_slot_payload_by_kind<T>(
value: &T,
kind: crate::model::field::FieldKind,
field_name: &'static str,
) -> Result<Vec<u8>, crate::error::InternalError>
where
T: crate::traits::PersistedByKindCodec,
{
crate::db::encode_persisted_slot_payload_by_kind(value, kind, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_slot_payload_by_kind<T>(
bytes: &[u8],
kind: crate::model::field::FieldKind,
field_name: &'static str,
) -> Result<T, crate::error::InternalError>
where
T: crate::traits::PersistedByKindCodec,
{
crate::db::decode_persisted_slot_payload_by_kind(bytes, kind, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_option_slot_payload_by_kind<T>(
bytes: &[u8],
kind: crate::model::field::FieldKind,
field_name: &'static str,
) -> Result<Option<T>, crate::error::InternalError>
where
T: crate::traits::PersistedByKindCodec,
{
crate::db::decode_persisted_option_slot_payload_by_kind(bytes, kind, field_name)
}
#[doc(hidden)]
pub fn encode_persisted_option_slot_payload_by_meta<T>(
value: &Option<T>,
field_name: &'static str,
) -> Result<Vec<u8>, crate::error::InternalError>
where
T: crate::traits::PersistedFieldMetaCodec,
{
crate::db::encode_persisted_option_slot_payload_by_meta(value, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_option_slot_payload_by_meta<T>(
bytes: &[u8],
field_name: &'static str,
) -> Result<Option<T>, crate::error::InternalError>
where
T: crate::traits::PersistedFieldMetaCodec,
{
crate::db::decode_persisted_option_slot_payload_by_meta(bytes, field_name)
}
#[doc(hidden)]
pub fn encode_persisted_many_slot_payload_by_meta<T>(
value: &[T],
field_name: &'static str,
) -> Result<Vec<u8>, crate::error::InternalError>
where
T: crate::traits::FieldTypeMeta + crate::traits::RuntimeValueEncode,
{
crate::db::encode_persisted_many_slot_payload_by_meta(value, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_many_slot_payload_by_meta<T>(
bytes: &[u8],
field_name: &'static str,
) -> Result<Vec<T>, crate::error::InternalError>
where
T: crate::traits::FieldTypeMeta + crate::traits::RuntimeValueDecode,
{
crate::db::decode_persisted_many_slot_payload_by_meta(bytes, field_name)
}
#[doc(hidden)]
pub fn encode_persisted_slot_payload_by_meta<T>(
value: &T,
field_name: &'static str,
) -> Result<Vec<u8>, crate::error::InternalError>
where
T: crate::traits::PersistedFieldMetaCodec,
{
crate::db::encode_persisted_slot_payload_by_meta(value, field_name)
}
#[doc(hidden)]
pub fn decode_persisted_slot_payload_by_meta<T>(
bytes: &[u8],
field_name: &'static str,
) -> Result<T, crate::error::InternalError>
where
T: crate::traits::PersistedFieldMetaCodec,
{
crate::db::decode_persisted_slot_payload_by_meta(bytes, field_name)
}
}