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;
16use reifydb_macro_impl::derive_from_frame_with_crate;
17
18/// Derives `FromFrame` for a struct, enabling deserialization from a Frame.
19///
20/// Generated code references types from the `reifydb_client` crate.
21///
22/// # Attributes
23///
24/// - `#[frame(column = "name")]` - Use a different column name than the field name
25/// - `#[frame(optional)]` - Field is optional; missing columns or None values become None
26/// - `#[frame(coerce)]` - Use widening type coercion for this field
27/// - `#[frame(skip)]` - Skip this field (must implement Default)
28#[proc_macro_derive(FromFrame, attributes(frame))]
29pub fn derive_from_frame(input: TokenStream) -> TokenStream {
30	derive_from_frame_with_crate(input.into(), "reifydb_client").into()
31}