Expand description
A library for writing Cairo procedural macros in Rust.
§Cairo procedural macro
A Cairo procedural macro is a dynamic library that can be loaded by Scarb package manager during the project build. The goal of procedural macros is to provide dynamic code generation capabilities to Cairo programmers.
The code generation should be implemented as a Rust function, that takes TokenStream
as
input and returns ProcMacroResult
as output.
The function implementing the macro should be wrapped with attribute_macro
.
Macros§
Structs§
- Allocation
Context - A context for allocating Cairo tokens. This wrapper contains a bump allocator, which is used to allocate strings for tokens.
- AuxData
- Auxiliary data returned by procedural macro code generation.
- Diagnostic
- Diagnostic returned by the procedural macro.
- Diagnostics
- A set of diagnostics that arose during the computation.
- Full
Path Marker - Full path marker.
- Interned
Str - A wrapper over a string pointer. This contains a pointer to a string allocated in a bump allocator and a guard which keeps the buffer alive. This way we do not need to allocate a new string, but also do not need to worry about the lifetime of the string.
- Post
Process Context - Input for the post-process callback.
- Proc
Macro Result - Result of procedural macro code generation.
- Text
Span - A range of text offsets that form a span (like text selection).
- Token
- A single Cairo token.
- Token
Stream - An abstract stream of Cairo tokens.
- Token
Stream Metadata - Metadata of
TokenStream
.
Enums§
- Expansion
Func - Severity
- The severity of a diagnostic.
- Token
Tree - A single token or a delimited sequence of token trees.
Statics§
Type Aliases§
Attribute Macros§
- attribute_
macro - Constructs the attribute macro implementation.
- derive_
macro - Constructs the derive macro implementation.
- fingerprint
- Constructs the fingerprint callback.
- inline_
macro - Constructs the inline macro implementation.
- post_
process - Constructs the post-processing callback.