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::{
32    CancellationReason, EmbeddingError, EmbeddingModelMeta, EmbeddingProvider,
33    EmbeddingProviderRegistry, EmbeddingSource as CoreEmbeddingSource, FixedVectorProvider,
34    IndexBuildPolicy, TriggerConfig,
35};
36pub use mongreldb_query::{
37    CancelOutcome, QueryId, QueryTerminalErrorCategory, QueryTerminalState, SerializationOutcome,
38    SqlQueryPhase,
39};
40pub use query::JoinRow;
41#[cfg(feature = "remote")]
42pub use remote::{
43    RemoteAuth, RemoteBatch, RemoteCancelOutcome, RemoteDatabase, RemoteIdempotentSqlOptions,
44    RemoteOpResult, RemoteOptions, RemoteQueryRow, RemoteQueryStatus, RemoteSqlFormat,
45    RemoteSqlOptions, RemoteSqlPage, RemoteSqlPageInfo, RemoteSqlPageLimits,
46    RemoteSqlPaginationOptions, RemoteSqlQueryHandle, RemoteSqlReceiptError, RemoteSqlWriteReceipt,
47    RemoteTransaction, SecretString, SqlCancellationCapabilities, SqlIdempotencyCapabilities,
48    SqlPaginationCapabilities,
49};
50pub use schema::Row;
51pub use search::{
52    SearchComponent, SearchHit, SearchMetric, SearchRerank, SearchRetriever, SearchSpec,
53};
54pub use txn::Transaction;
55
56// Re-export the core model so downstream consumers can depend on a single crate.
57pub use mongreldb_kit_core::*;
58
59#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
60pub struct BuildInfo {
61    pub artifact_version: &'static str,
62    pub engine_version: &'static str,
63    pub query_version: &'static str,
64    pub kit_version: &'static str,
65    pub mongreldb_git_sha: &'static str,
66    pub kit_git_sha: &'static str,
67}
68
69pub fn build_info() -> BuildInfo {
70    BuildInfo {
71        artifact_version: env!("CARGO_PKG_VERSION"),
72        engine_version: env!("CARGO_PKG_VERSION"),
73        query_version: env!("CARGO_PKG_VERSION"),
74        kit_version: env!("CARGO_PKG_VERSION"),
75        mongreldb_git_sha: env!("MONGRELDB_GIT_SHA"),
76        kit_git_sha: env!("MONGRELDB_KIT_GIT_SHA"),
77    }
78}
79
80#[cfg(test)]
81mod build_info_tests {
82    #[test]
83    fn build_info_reports_one_component_train() {
84        let info = super::build_info();
85        assert_eq!(info.artifact_version, env!("CARGO_PKG_VERSION"));
86        assert_eq!(info.engine_version, info.query_version);
87        assert_eq!(info.query_version, info.kit_version);
88        assert!(info.mongreldb_git_sha == "unknown" || info.mongreldb_git_sha.len() == 40);
89        assert_eq!(info.kit_git_sha.len(), 40);
90    }
91}