Skip to main content

Crate oraclemcp_driver_cx_derive

Crate oraclemcp_driver_cx_derive 

Source
Expand description

Procedural macros for the oraclemcp-driver-cx driver.

This crate hosts the #[derive(FromRow)] macro. It is an implementation detail of the oraclemcp-driver-cx crate: end users never depend on it directly. The driver crate re-exports the derive (gated behind its default-on derive feature) alongside the FromRow trait the generated code implements, so the single import

ⓘ
use oraclemcp_driver_cx::FromRow;

brings both the trait and the derive into scope.

§What the derive generates

For a struct

ⓘ
#[derive(FromRow)]
struct Emp { id: i64, name: String, hired: Option<chrono::NaiveDate> }

the macro emits an impl oraclemcp_driver_cx::FromRow for Emp, whose from_row pulls each field out of the row by column name through the existing typed accessor (TypedRow::get_by_name), which itself goes through the real FromSql conversion. There is no stringly-typed shortcut: an i64 field is genuinely converted from the Oracle NUMBER, an Option<T> field accepts a SQL NULL, and a chrono::NaiveDate field is decoded from a DATE.

§Supported shapes and attributes

  • Named-field structs — each field maps to a column named after the field.
  • Tuple structs — each field maps to a column by position (index 0, 1, …).
  • #[driver_cx(rename_all = "UPPERCASE" | "lowercase" | "snake_case" | "SCREAMING_SNAKE_CASE" | "camelCase" | "PascalCase")] on the struct renames every field’s column (column resolution is case-insensitive, so UPPERCASE/lowercase are cosmetic, but the others change word casing).
  • #[driver_cx(column = "…")] on a field overrides that one column name.
  • #[driver_cx(rename = "…")] is an accepted alias for column = "…".

Enums, unions, and unit/zero-field structs produce a clear compile_error!.

Derive Macros§

FromRow
Derive an oraclemcp_driver_cx::FromRow implementation that maps a query row into the annotated struct, with compile-time-checked field types.