//! Core library for the **SpatioTemporal Tiles (STT)** format.
//!
//! The canonical container is the **packed format** ([`pack`]): a per-dataset
//! `manifest.json` plus many content-addressed, immutable pack objects
//! (`packs/<blake3>.sttp`) and one directory object (`index/<blake3>.sttd`).
//! Splitting a dataset into small, immutable objects is what makes it
//! edge-cacheable on a plain CDN — see `docs/spec/stt-packed-format.md`.
//!
//! Building blocks:
//! - [`pack`] — the packed format: [`PackWriter`], [`PackedReader`], [`Manifest`],
//!   [`verify_packed_objects`].
//! - [`arrow_tile`] — Arrow-IPC tile payloads with GeoArrow geometry.
//! - [`directory`] — the run-length tile directory (v5) and its [`TileEntry`].
//! - [`curve`] — spatial (Hilbert) + temporal blob ordering.
//! - [`metadata`] — dataset metadata (folded verbatim into the manifest).
//! - [`compression`] — per-blob zstd.

pub mod arrow_tile;
pub mod budget;
pub mod compression;
pub mod curve;
pub mod directory;
pub mod directory_page;
pub mod error;
pub mod geometry;
pub mod metadata;
pub mod ordering_sim;
pub mod pack;
pub mod projection;
pub mod tile;
pub mod timestamp;
pub mod types;

// Re-export commonly used types.
// Packed format — the canonical container.
pub use pack::{verify_packed_objects, Manifest, PackWriter, PackedReader};
pub use directory::TileEntry;
pub use directory_page::{
    decode_paged_directory, encode_paged_directory, verify_paged_structure, PageDescriptor,
    PagedRoot, DEFAULT_PAGE_ENTRIES,
};
pub use curve::BlobOrdering;
pub use ordering_sim::{
    evaluate as evaluate_orderings, measured_ordering, OrderingCost, QueryCost, SimOptions,
    TileSample, CANDIDATES, DEFAULT_COALESCE_GAP_BYTES,
};
pub use error::{Error, Result};
pub use tile::TileId;
pub use timestamp::{
    normalize_timestamp_to_ms, reject_negative_timestamp, scale_timestamp_to_ms, TimestampUnit,
};
pub use types::{BoundingBox, TimeRange};

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_tile_id_ordering() {
        let t1 = TileId::new(10, 512, 384, 1609459200000);
        let t2 = TileId::new(10, 512, 384, 1609545600000);
        assert!(t1 < t2);
    }
}
