Skip to main content

mongreldb_kit/
lib.rs

1//! Storage-backed MongrelDB Kit crate.
2//!
3//! This crate wraps MongrelDB core with the kit schema model, transaction
4//! semantics, query execution, and migration runner.
5pub mod arrow_util;
6pub mod db;
7pub mod error;
8pub(crate) mod internal;
9pub mod migrate;
10pub mod pushdown;
11pub mod query;
12#[cfg(feature = "remote")]
13pub mod remote;
14pub mod schema;
15pub mod search;
16pub mod tsv;
17pub mod txn;
18
19pub use db::{
20    ApproxAggKind, ApproxAggregate, Database, ExplainPlan, IncrementalAggKind,
21    IncrementalAggregate, OpenOptions, SimilarRow, SqlOptions, SqlOutputLimits, SqlQueryHandle,
22};
23// Re-export the engine tuning/config types so kit consumers (and the Python
24// binding, which depends only on this crate) can reach them without a direct
25// `mongreldb-core` dependency.
26pub use error::{KitError, QueryErrorMetadata, QueryExecutionOutcome, Result};
27pub use migrate::migrate;
28pub use mongreldb_core::auth::{Permission, RoleEntry, UserEntry};
29pub use mongreldb_core::auth_state::{AuthState, RequiredPermission, TableAuthChecker};
30pub use mongreldb_core::cache::CacheStats;
31pub use mongreldb_core::{CancellationReason, IndexBuildPolicy, TriggerConfig};
32pub use mongreldb_query::{
33    CancelOutcome, QueryId, QueryTerminalErrorCategory, QueryTerminalState, SerializationOutcome,
34    SqlQueryPhase,
35};
36pub use query::JoinRow;
37#[cfg(feature = "remote")]
38pub use remote::{
39    RemoteAuth, RemoteBatch, RemoteCancelOutcome, RemoteDatabase, RemoteIdempotentSqlOptions,
40    RemoteOpResult, RemoteOptions, RemoteQueryRow, RemoteQueryStatus, RemoteSqlFormat,
41    RemoteSqlOptions, RemoteSqlPage, RemoteSqlPageInfo, RemoteSqlPageLimits,
42    RemoteSqlPaginationOptions, RemoteSqlQueryHandle, RemoteSqlReceiptError, RemoteSqlWriteReceipt,
43    RemoteTransaction, SecretString, SqlCancellationCapabilities, SqlIdempotencyCapabilities,
44    SqlPaginationCapabilities,
45};
46pub use schema::Row;
47pub use search::{
48    SearchComponent, SearchHit, SearchMetric, SearchRerank, SearchRetriever, SearchSpec,
49};
50pub use txn::Transaction;
51
52// Re-export the core model so downstream consumers can depend on a single crate.
53pub use mongreldb_kit_core::*;
54
55#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
56pub struct BuildInfo {
57    pub artifact_version: &'static str,
58    pub engine_version: &'static str,
59    pub query_version: &'static str,
60    pub kit_version: &'static str,
61    pub mongreldb_git_sha: &'static str,
62    pub kit_git_sha: &'static str,
63}
64
65pub fn build_info() -> BuildInfo {
66    BuildInfo {
67        artifact_version: env!("CARGO_PKG_VERSION"),
68        engine_version: env!("CARGO_PKG_VERSION"),
69        query_version: env!("CARGO_PKG_VERSION"),
70        kit_version: env!("CARGO_PKG_VERSION"),
71        mongreldb_git_sha: env!("MONGRELDB_GIT_SHA"),
72        kit_git_sha: env!("MONGRELDB_KIT_GIT_SHA"),
73    }
74}
75
76#[cfg(test)]
77mod build_info_tests {
78    #[test]
79    fn build_info_reports_one_component_train() {
80        let info = super::build_info();
81        assert_eq!(info.artifact_version, env!("CARGO_PKG_VERSION"));
82        assert_eq!(info.engine_version, info.query_version);
83        assert_eq!(info.query_version, info.kit_version);
84        assert!(info.mongreldb_git_sha == "unknown" || info.mongreldb_git_sha.len() == 40);
85        assert_eq!(info.kit_git_sha.len(), 40);
86    }
87}