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#![cfg_attr(not(debug_assertions), deny(warnings))]
6#![allow(clippy::tabs_in_doc_comments)]
7
8pub mod from_frame;
9pub mod generate;
10pub mod parse;
11
12use proc_macro2::TokenStream;
13
14/// Derive `FromFrame` with the default crate path (reifydb_type).
15pub fn derive_from_frame(input: TokenStream) -> TokenStream {
16	derive_from_frame_with_crate(input, "reifydb_type")
17}
18
19/// Derive `FromFrame` with a custom crate path.
20///
21/// # Arguments
22/// * `input` - The derive macro input TokenStream
23/// * `crate_path` - The crate path to use (e.g., "reifydb", "reifydb_client", "reifydb_type")
24pub fn derive_from_frame_with_crate(input: TokenStream, crate_path: &str) -> TokenStream {
25	match parse::parse_struct_with_crate(input, crate_path) {
26		Ok(parsed) => from_frame::expand(parsed),
27		Err(err) => err,
28	}
29}