7 releases

new 0.2.1 Nov 13, 2024
0.2.0 Nov 13, 2024
0.1.52 Nov 11, 2024
0.1.1 Oct 22, 2024

#17 in #carbon

Download history 240/week @ 2024-10-16 115/week @ 2024-10-23 48/week @ 2024-10-30 274/week @ 2024-11-06

677 downloads per month
Used in 13 crates

MIT license

33KB
240 lines

Carbon Proc Macros

carbon-proc-macros is a collection of procedural macros designed to simplify and enhance Rust-based development for Solana programs using the Carbon framework. This crate provides macros for generating deserialization implementations, instruction decoders, and type conversions.

Overview

The macros in this crate are intended to streamline common patterns encountered when working with Carbon, particularly around deserialization, instruction decoding, and structuring custom types. By leveraging carbon-proc-macros, you can reduce the amount of manual coding and ensure consistent, performant handling of Solana-specific data structures.

Key Features

  • CarbonDeserialize: Automatically implement the CarbonDeserialize trait for structs and enums, enabling Borsh-based deserialization with optional discriminators for type validation.
  • Instruction Decoder Collection: Create and manage complex instruction decoders for multiple Solana programs, simplifying how instructions are parsed and categorized.
  • InstructionType Derivation: Derive InstructionType enums that mirror existing enum structures, providing a simplified, data-free version of each variant.

Usage

To use any of the provided macros, simply import the desired macro into your Rust program and apply it to the relevant struct or enum.

Notes

  • This crate relies on the borsh library for serialization and deserialization, so ensure the relevant dependencies are included in your project.
  • The macros provided are optimized for use within the Carbon framework.

Contribution

Contributions are welcome! If you have ideas for improving or expanding the functionality of carbon_macros, please consider submitting a pull request or opening an issue on the project’s GitHub repository.

Dependencies

~72MB
~1.5M SLoC