Skip to main content

reifydb_client_derive/
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#![allow(clippy::tabs_in_doc_comments)]
6// SPDX-License-Identifier: Apache-2.0
7// Copyright (c) 2025 ReifyDB
8// This file is licensed under the MIT, see license.md file
9
10//! Derive macros for ReifyDB client that generate code using `reifydb_client` crate paths.
11//!
12//! This crate is re-exported by the `reifydb-client` crate, so users typically don't
13//! need to depend on it directly.
14
15use proc_macro::TokenStream;
16
17/// Derives `FromFrame` for a struct, enabling deserialization from a Frame.
18///
19/// Generated code references types from the `reifydb_client` crate.
20///
21/// # Attributes
22///
23/// - `#[frame(column = "name")]` - Use a different column name than the field name
24/// - `#[frame(optional)]` - Field is optional; missing columns or None values become None
25/// - `#[frame(coerce)]` - Use widening type coercion for this field
26/// - `#[frame(skip)]` - Skip this field (must implement Default)
27#[proc_macro_derive(FromFrame, attributes(frame))]
28pub fn derive_from_frame(input: TokenStream) -> TokenStream {
29	reifydb_macro_impl::derive_from_frame_with_crate(input.into(), "reifydb_client").into()
30}