Crate cairo_lang_macro

Crate cairo_lang_macro 

Source
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§

executable_attribute
quote

Structs§

AllocationContext
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.
FullPathMarker
Full path marker.
InternedStr
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.
PostProcessContext
Input for the post-process callback.
ProcMacroResult
Result of procedural macro code generation.
TextSpan
A range of text offsets that form a span (like text selection).
Token
A single Cairo token.
TokenStream
An abstract stream of Cairo tokens.
TokenStreamMetadata
Metadata of TokenStream.

Enums§

ExpansionFunc
Severity
The severity of a diagnostic.
TokenTree
A single token or a delimited sequence of token trees.

Statics§

CAIRO_LANG_MACRO_API_VERSION

Type Aliases§

TextOffset

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.