mod accepted;
mod binary;
mod composite;
mod encode;
mod leaf;
mod primary_key_component;
mod primitive;
mod scalar;
mod typed;
mod value_storage;
use crate::{model::field::FieldKind, value::Value};
use composite::{decode_composite_field_by_kind_bytes, validate_composite_field_by_kind_bytes};
use leaf::decode_leaf_field_by_kind_bytes;
use scalar::decode_scalar_fast_path_bytes;
pub(in crate::db) use accepted::{
accepted_kind_supports_primary_key_component_binary,
decode_structural_field_by_accepted_kind_bytes, encode_structural_field_by_accepted_kind_bytes,
validate_structural_field_by_accepted_kind_bytes,
};
pub(in crate::db) use encode::encode_structural_field_by_kind_bytes;
pub(in crate::db) use primary_key_component::decode_accepted_relation_target_primary_key_components_bytes;
pub(in crate::db) use value_storage::{
ValueStorageView, decode_canonical_value_storage_bytes, decode_structural_value_storage_bytes,
encode_canonical_value_storage_bytes, encode_structural_value_storage_null_bytes,
validate_structural_value_storage_bytes, value_storage_bytes_are_null,
};
#[derive(Clone, Debug)]
pub(in crate::db) struct FieldDecodeError;
impl FieldDecodeError {
pub(in crate::db) const fn new() -> Self {
Self
}
}
pub(in crate::db) fn decode_structural_field_by_kind_bytes(
raw_bytes: &[u8],
kind: FieldKind,
) -> Result<Value, FieldDecodeError> {
if let Some(value) = decode_scalar_fast_path_bytes(raw_bytes, kind)? {
return Ok(value);
}
if let Some(value) = decode_leaf_field_by_kind_bytes(raw_bytes, kind)? {
return Ok(value);
}
decode_composite_field_by_kind_bytes(raw_bytes, kind)
}
pub(in crate::db) fn validate_structural_field_by_kind_bytes(
raw_bytes: &[u8],
kind: FieldKind,
) -> Result<(), FieldDecodeError> {
if decode_scalar_fast_path_bytes(raw_bytes, kind)?.is_some() {
return Ok(());
}
if decode_leaf_field_by_kind_bytes(raw_bytes, kind)?.is_some() {
return Ok(());
}
validate_composite_field_by_kind_bytes(raw_bytes, kind)
}