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