reifydb-core 0.10.1

Core database interfaces and data structures for ReifyDB
Documentation
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2026 ReifyDB

use reifydb_value::{
	error::{Error, IntoDiagnostic, TypeError},
	fragment::Fragment,
	value::{duration::Duration, value_type::ValueType},
};

pub mod diagnostic;

#[derive(Debug, thiserror::Error)]
pub enum CoreError {
	#[error(transparent)]
	Type(#[from] TypeError),

	#[error("variable-length types (UTF8, BLOB) are not supported in indexes")]
	IndexVariableLengthNotSupported,

	#[error("mismatch between number of types ({types_len}) and directions ({directions_len})")]
	IndexTypesDirectionsMismatch {
		types_len: usize,
		directions_len: usize,
	},

	#[error("Frame processing error: {message}")]
	FrameError {
		message: String,
	},

	#[error("cannot append rows: '{column}' is present on one side but not the other")]
	AppendSystemColumnMismatch {
		column: String,
	},

	#[error("operator setting '{key}' is a count ({count}), but this operator seals by time")]
	OperatorWithCountSpan {
		key: &'static str,
		count: u64,
	},

	#[error("immutable {immutable} must be strictly less than lateness {lateness}")]
	OperatorWithImmutableNotBelowLateness {
		immutable: Duration,
		lateness: Duration,
	},

	#[error("this operator needs 'window' in its with block")]
	OperatorWithWindowMissing,

	#[error("this operator needs 'pane' in its rolling window's with block")]
	OperatorWithPaneMissing,

	#[error("window '{kind}' is not supported by this operator, use '{supported}'")]
	OperatorWithWindowKindUnsupported {
		kind: &'static str,
		supported: String,
	},

	#[error("this operator takes no window, but window '{kind}' was given")]
	OperatorWithWindowNotSupported {
		kind: &'static str,
	},

	#[error("the window size is a count ({count}), but this operator windows by time")]
	OperatorWithWindowSizeCount {
		count: u64,
	},

	#[error("the window size is a duration ({size}), but this operator counts slots")]
	OperatorWithWindowSizeDuration {
		size: Duration,
	},

	#[error("the window slide is a count ({count}), but this operator windows by time")]
	OperatorWithWindowSlideCount {
		count: u64,
	},

	#[error("the window slide is a duration ({slide}), but this operator counts slots")]
	OperatorWithWindowSlideDuration {
		slide: Duration,
	},

	#[error("a session window seals on its gap and takes no lateness (lateness: {lateness})")]
	OperatorWithSessionLateness {
		lateness: Duration,
	},

	#[error("a session window needs a gap above zero")]
	OperatorWithSessionZeroGap,

	#[error("operator setting '{key}' is a duration ({duration}), but this operator seals by count")]
	OperatorWithDurationSpan {
		key: &'static str,
		duration: Duration,
	},

	#[error("a nostate operator takes no 'with'")]
	OperatorWithNotAccepted,

	#[error("a managed operator needs 'retention' or 'lateness'")]
	OperatorRetentionRequired,

	#[error("this operator takes no 'retention'")]
	OperatorWithRetentionNotSupported,

	#[error("retention {retention} must not be below lateness {lateness}")]
	OperatorWithRetentionBelowLateness {
		retention: Duration,
		lateness: Duration,
	},

	#[error("timer kind '{kind}' is reserved for the engine")]
	OperatorTimerKindReserved {
		kind: &'static str,
	},

	#[error("cannot use column `{column}` in a primary key: a {ty} value cannot be a key")]
	PrimaryKeyDigestColumn {
		fragment: Fragment,
		column: String,
		ty: ValueType,
	},

	#[error("expected {expected}, got {actual}")]
	DigestWriteTypeMismatch {
		fragment: Fragment,
		expected: ValueType,
		actual: ValueType,
	},

	#[error("sequence generator of type `{value_type}` is exhausted")]
	SequenceExhausted {
		value_type: ValueType,
	},

	#[error("{subsystem} subsystem initialization failed: {reason}")]
	SubsystemInitFailed {
		subsystem: String,
		reason: String,
	},

	#[error("Required feature '{feature}' is not enabled")]
	SubsystemFeatureDisabled {
		feature: String,
	},

	#[error("Failed to bind to {addr}: {reason}")]
	SubsystemBindFailed {
		addr: String,
		reason: String,
	},

	#[error("Failed to get local address: {reason}")]
	SubsystemAddressUnavailable {
		reason: String,
	},
}

impl From<CoreError> for Error {
	fn from(err: CoreError) -> Self {
		Error(Box::new(err.into_diagnostic()))
	}
}