Skip to main content

chronix_core/
lib.rs

1//! # chronix-core
2//!
3//! Core data model, types, errors, and configuration for the Chronix time-series
4//! database. This crate provides the foundational types that all other Chronix
5//! crates depend on.
6//!
7//! ## Overview
8//!
9//! - **Data model:** [`FieldValue`], [`SeriesKey`], [`Point`] — the fundamental
10//!   units of time-series data.
11//! - **Exact decimals:** [`Decimal`] — `mantissa × 10⁻ˢᶜᵃˡᵉ` for the one class
12//!   of series whose value is a legal quantity: metering, billing and
13//!   settlement. See [`decimal`] for why a `f64` cannot carry those.
14//! - **Schema:** [`MeasurementSchema`], [`SchemaRegistry`] — schema-on-write with
15//!   additive evolution.
16//! - **Calendar buckets:** [`TimeBucket`] — the one answer to "what is a day",
17//!   shared by SQL's `time_bucket()`, a rollup tier and the native
18//!   `downsample()` plan, so the three cannot disagree. See [`timebucket`].
19//! - **Errors:** [`ChronixError`] — crate-level and top-level error hierarchy.
20//! - **Configuration:** [`ChronixConfig`], [`WalConfig`] — full database
21//!   configuration with builder pattern.
22
23#![warn(missing_docs)]
24#![deny(unsafe_code)]
25#![allow(clippy::module_name_repetitions)]
26
27pub mod config;
28pub mod decimal;
29pub mod error;
30pub mod schema;
31pub mod timebucket;
32pub mod types;
33pub mod wal_codec;
34
35pub use config::{
36    AnalyticsConfig, Checkpoints, ChronixConfig, ChronixConfigBuilder, CompressionCodec,
37    FieldEncryption, FloatEncoding, FsyncPolicy, WalConfig,
38};
39pub use decimal::{
40    pow10, Decimal, DecimalError, DECIMAL_PRECISION, MAX_DECIMAL_MANTISSA, MAX_DECIMAL_SCALE,
41};
42pub use error::{ChronixError, ConfigError, SchemaError, WalError};
43pub use schema::{
44    ColumnDef, ColumnRole, ColumnType, MeasurementSchema, SchemaAction, SchemaRegistry,
45};
46pub use timebucket::{BucketParseError, BucketWidth, TimeBucket};
47pub use types::{
48    canonical_from_pairs, push_canonical, FieldValue, Fields, NamespaceId, NamespaceQuota,
49    NamespaceUsage, Point, SegmentFile, SegmentId, SegmentState, SeriesKey, ShardId, Tags,
50    Timestamp, Tombstone, TombstoneSet, WalEntry, KV_SEPARATOR, MAX_STRING_FIELD_LENGTH,
51    NAMESPACE_TAG, RESERVED_COLUMN_NAMES, TAG_SEPARATOR, TIME_COLUMN,
52};
53pub use wal_codec::{
54    decode as wal_decode, encode as wal_encode, encode_write_point as wal_encode_write_point,
55    CodecError as WalCodecError,
56};