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