Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rust SDK Reference (schemabound)

The schemabound crate is the core Rust runtime and reference implementation of the OAM framework. All other SDKs and services build on this foundation.

Crate Structure

ModulePurpose
schemabound::mirrorSQLite schema introspection — tables, columns, indexes, triggers, UDTs, field mappings
schemabound::executorSchemaService / QueryService traits + SQLite implementations
schemabound::grpc_executorTonic gRPC server wrapping the executor services
schemabound::interceptorTyped event bus — Event enum, EventBus, EventHandler, HandleOutcome
schemabound::handlersBuilt-in CoR handlers — AuditLogHandler, QueryMetricsHandler, SessionActivityHandler, DefaultHandlerChain, SharedHandler
schemabound::tcpTCP JSON-RPC transport and per-client auth
schemabound::policy_engineTool-contract policy evaluation and subquery governance
schemabound::runtime_contextQueryRuntimeContext — the carrier for per-request augmentation metadata
schemabound::rate_limitConnection and request rate limiter
schemabound::mapperMapper trait + LocalMapper (SQLite) + TcpMapper (remote)

Schema Introspection Model

The mirror module returns a tree of Rust structs:

SchemaModel
├── tables: Vec<Table>
│   ├── columns: Vec<Column>          name, sql_type, nullable, primary_key, default_value
│   ├── indexes: Vec<Index>           name, columns
│   ├── unique_indexes: Vec<UniqueIndex>
│   ├── foreign_keys: Vec<ForeignKey>
│   ├── composite_foreign_keys: Vec<CompositeForeignKey>
│   ├── triggers: Vec<Trigger>        name, event, timing, table_name, body
│   └── field_mappings: Vec<FieldMapping>
│       └── logical_name, physical_name, orm_convention  (Hibernate | EntityFramework)
└── user_defined_types: Vec<UserDefinedType>
    └── name, base_type, check_constraint, nullable, default_value

Field mapping convention detection is heuristic:

  • camelCase column names → Hibernate
  • PascalCase column names → EntityFramework (Entity Framework)
  • _prefixed columns → EntityFramework (EF Core shadow property convention)

gRPC Proto Mapping

The table_to_table_def function converts a mirror::Table to a proto TableDef:

#![allow(unused)]
fn main() {
use schemabound::grpc_executor::table_to_table_def;

let proto_table = table_to_table_def(&my_mirror_table);
}

Both unique_indexes and indexes are merged into TableDef.indexes, distinguished by IndexDef.is_unique.

Contributing

See the Contribution Workflow for the full TDD contract — no production code may be written before a failing test exists.

Test Targets

# Unit tests only (fast, no infra)
make test-unit

# Full test suite (schemabound-public)
make test FILTER=schemabound-public

# Proto unit tests
make test-proto