Skip to content

Modernize field!/sign!/hashmap! macros to emit typed SignatureSchema #73

@darinkishore

Description

@darinkishore

Context

lib.rs defines three macros:

  • field! (lines 46-133) — generates serde_json::Value maps via schemars. Only used in tests/test_field_macro.rs.
  • sign! (lines 135-171) — inline signature + Predict creation. Zero callers currently.
  • hashmap! (lines 178-187) — convenience HashMap literal. Used in tests/examples.

These are ergonomic features for the untyped path. field! and sign! use schemars::schema_for!() to generate JSON schemas, which is the pre-V1 approach. The typed path uses #[derive(Signature)] + SignatureSchema::of::<S>().

What's needed

field! macro

  • Should emit typed FieldSchema values instead of serde_json::Value maps
  • Or consider if #[derive(Signature)] makes this macro redundant

sign! macro

  • Should work with the typed Signature derive and produce a Predict<__InlineSignature> that's fully wired (accessor registration, etc.)
  • Currently generates a derive but doesn't call register_predict_accessor or build()

hashmap! macro

  • Low priority. HashMap::from([...]) is standard Rust. Keep or kill, doesn't matter much.

schemars dependency

  • __macro_support re-exports schemars solely for field!
  • Once field! is modernized, schemars can be dropped from Cargo.toml (also requires specials.rs migration, see related issue)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions