10 unstable releases (3 breaking)

new 0.4.0 Dec 19, 2024
0.3.1 Dec 1, 2024
0.3.0 Nov 21, 2024
0.2.1 Nov 13, 2024
0.1.1 Oct 22, 2024

#17 in #carbon

Download history 122/week @ 2024-10-13 184/week @ 2024-10-20 66/week @ 2024-10-27 52/week @ 2024-11-03 679/week @ 2024-11-10 325/week @ 2024-11-17 118/week @ 2024-11-24 295/week @ 2024-12-01 165/week @ 2024-12-08 287/week @ 2024-12-15

913 downloads per month
Used in carbon-core

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

~54–75MB
~1.5M SLoC