Skip to main content

reifydb_macro_impl/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3#![cfg_attr(not(debug_assertions), deny(clippy::disallowed_methods))]
4#![cfg_attr(debug_assertions, warn(clippy::disallowed_methods))]
5
6//! Implementation for ReifyDB derive macros.
7//!
8//! This crate provides the implementation logic used by proc-macro crates.
9//! It's not intended for direct use - use `reifydb-macro`, `reifydb-derive`,
10//! or `reifydb-client-derive` instead.
11
12#![cfg_attr(not(debug_assertions), deny(warnings))]
13#![allow(clippy::tabs_in_doc_comments)]
14
15pub mod from_frame;
16pub mod generate;
17pub mod parse;
18
19use proc_macro2::TokenStream;
20
21/// Derive `FromFrame` with the default crate path (reifydb_type).
22pub fn derive_from_frame(input: TokenStream) -> TokenStream {
23	derive_from_frame_with_crate(input, "reifydb_type")
24}
25
26/// Derive `FromFrame` with a custom crate path.
27///
28/// # Arguments
29/// * `input` - The derive macro input TokenStream
30/// * `crate_path` - The crate path to use (e.g., "reifydb", "reifydb_client", "reifydb_type")
31pub fn derive_from_frame_with_crate(input: TokenStream, crate_path: &str) -> TokenStream {
32	match parse::parse_struct_with_crate(input, crate_path) {
33		Ok(parsed) => from_frame::expand(parsed),
34		Err(err) => err,
35	}
36}