hyperstack-macros

Crates.iohyperstack-macros
lib.rshyperstack-macros
version0.3.5
created_at2026-01-09 05:37:31.179398+00
updated_at2026-01-24 05:37:40.678346+00
descriptionProc-macros for defining HyperStack streams
homepage
repositoryhttps://github.com/HyperTekOrg/hyperstack.git
max_upload_size
id2031624
size528,218
Adrian (adiman9)

documentation

https://docs.rs/hyperstack-macros

README

hyperstack-macros

crates.io docs.rs License

Procedural macros for defining HyperStack streams.

Overview

This crate provides the #[hyperstack] attribute macro that transforms annotated Rust structs into full streaming pipeline specifications, including:

  • State struct generation with field accessors
  • Handler creation functions for event processing
  • IDL/Proto parser integration for Solana programs
  • Automatic AST serialization for deployment

Installation

[dependencies]
hyperstack-macros = "0.2"

Usage

IDL-based Stream

use hyperstack_macros::{hyperstack, Stream};

#[hyperstack(idl = "idl.json")]
pub mod my_stream {
    #[entity(name = "MyEntity")]
    #[derive(Stream)]
    struct Entity {
        #[map(from = "MyAccount", field = "value")]
        pub value: u64,
        
        #[map(from = "MyAccount", field = "owner")]
        pub owner: String,
    }
}

Proto-based Stream

#[hyperstack(proto = ["events.proto"])]
pub mod my_stream {
    // entity structs
}

Supported Attributes

Attribute Description
#[map(...)] Map from account fields
#[from_instruction(...)] Map from instruction fields
#[event(...)] Capture instruction events
#[snapshot(...)] Capture entire source data
#[aggregate(...)] Aggregate field values
#[computed(...)] Computed fields from other fields
#[derive_from(...)] Derive values from instructions

Generated Output

The macro generates:

  • {EntityName}State struct with all fields
  • fields:: module with field accessors
  • create_spec() function returning TypedStreamSpec
  • Handler creation functions for each source

License

Apache-2.0

Commit count: 0

cargo fmt