resolute-derive 0.1.0

Derive macros for resolute (FromRow, PgEnum, PgComposite, PgDomain).
Documentation
  • Coverage
  • 100%
    6 out of 6 items documented0 out of 5 items with examples
  • Size
  • Source code size: 58.08 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 416.74 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 27s Average build duration of successful builds.
  • all releases: 27s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • joshburgess/resolute
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • joshburgess

resolute-derive

Proc-macro crate backing the #[derive(...)] and attribute macros exposed at the resolute crate root. You don't need to depend on this directly: re-exports live in resolute itself.

What it provides

  • #[derive(FromRow)]: map a row (from query, query!, a stream, or COPY) into a struct. Field attributes: rename, skip, default, json (serde round-trip), try_from = "T", flatten (compose nested structs).
  • #[derive(PgEnum)]: PostgreSQL enum types. Works in #[repr(i32)] mode too, which is handy for legacy schemas where the status column is a bare integer.
  • #[derive(PgComposite)]: custom composite types, including their array OIDs.
  • #[derive(PgDomain)]: newtypes over a base SQL type, with automatic array-OID inheritance.
  • #[resolute::test]: test attribute that spins up a temporary database, runs migrations, hands the test a Client, and cleans up on completion.

Usage

use resolute::FromRow;

#[derive(FromRow)]
struct Author {
    id: i32,
    name: String,
    #[from_row(default)]
    bio: Option<String>,
}

Testing

resolute-derive has no dedicated test target. Instead:

  • Successful expansion is exercised by every derive in the resolute crate's tests (~378 tests in resolute/tests/), which import the macros and rely on the generated code at runtime.
  • Compile-time failure is covered by trybuild fixtures in resolute/tests/compile_fail_derive/, run by derive_compile_fail_tests in resolute/tests/compile_fail_derive_test.rs. Each .rs fixture has a paired .stderr snapshot that the harness diffs against the actual compiler output.

This setup catches both "the macro produced wrong code" (via downstream runtime tests) and "the macro accepted invalid input" (via trybuild) without requiring a separate tests/ directory inside this crate.

License

Dual licensed under Apache 2.0 or MIT. See the workspace root for the broader project.