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 histogram;
31pub mod schema;
32pub mod timebucket;
33pub mod types;
34pub mod wal_codec;
35
36pub use config::{
37    AnalyticsConfig, Checkpoints, ChronixConfig, ChronixConfigBuilder, CompressionCodec,
38    FieldEncryption, FloatEncoding, FsyncPolicy, WalConfig,
39};
40pub use decimal::{
41    DECIMAL_PRECISION, Decimal, DecimalError, MAX_DECIMAL_MANTISSA, MAX_DECIMAL_SCALE, pow10,
42};
43pub use error::{ChronixError, ConfigError, SchemaError, WalError};
44pub use schema::{
45    ColumnDef, ColumnRole, ColumnType, MeasurementSchema, SchemaAction, SchemaRegistry,
46};
47pub use timebucket::{BucketParseError, BucketWidth, TimeBucket};
48pub use types::{
49    FieldValue, Fields, KV_SEPARATOR, MAX_STRING_FIELD_LENGTH, NAMESPACE_TAG, NamespaceId,
50    NamespaceQuota, NamespaceUsage, Point, RESERVED_COLUMN_NAMES, SegmentFile, SegmentId,
51    SegmentState, SeriesKey, ShardId, TAG_SEPARATOR, TIME_COLUMN, Tags, Timestamp, Tombstone,
52    TombstoneSet, WalEntry, canonical_from_pairs, push_canonical,
53};
54pub use wal_codec::{
55    CodecError as WalCodecError, decode as wal_decode, encode as wal_encode,
56    encode_write_point as wal_encode_write_point,
57};