1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
extern crate proc_macro;
use TokenStream;
/// Derive macro for creating opaque types for cxx-cel.
///
/// # Attributes
/// - `type = "..."`: The type name of the opaque type.
/// - `display`: Generates `impl std::fmt::Display` with `Debug` trait.
/// - `display = EXPR`: Generates `impl std::fmt::Display` with the given expression.
/// - `crate = ...`: The crate name of the cel_cxx crate, if you are using a different crate name in Cargo.toml.
///
/// # Example
///
/// ```ignore
/// #[derive(Opaque, Debug, Clone, PartialEq)]
/// #[cel_cxx(type = "my_app.my_module.User")]
/// // Generates `std::fmt::Display` impl with `Debug` trait.
/// #[cel_cxx(display)]
/// // or you can specify a custom format.
/// // Generates `std::fmt::Display` impl with custom format.
/// #[cel_cxx(display = write!(fmt, "User(id={id}, name={name})", id = self.id, name = self.name))]
/// struct User {
/// id: i32,
/// name: String,
/// email: String,
/// }
/// ```
///
///
/// Derive macro for prost-generated protobuf types.
///
/// Generates `TypedValue`, `IntoValue`, `FromValue`, `From<T>` for `Value`,
/// and `TryFrom<Value>` implementations using prost serialization.
///
/// # Requirements
///
/// The type must implement `prost::Message` and `prost::Name`.
/// Enable `prost::Name` generation via `.enable_type_names()` in prost-build.
///
/// # Attributes
/// - `type_name = "..."`: Override the protobuf type name (default: `prost::Name::full_name()`).
/// - `crate = ...`: Custom path to the cel_cxx crate.
///
/// # Setup
///
/// In your `build.rs`, inject the derive via `type_attribute()`:
///
/// ```rust,ignore
/// // build.rs
/// prost_build::Config::new()
/// .enable_type_names()
/// .type_attribute("my.package.MyMessage", "#[derive(::cel_cxx::ProstValue)]")
/// .compile_protos(&["proto/my.proto"], &["proto/"])
/// .unwrap();
/// ```
/// Derive macro for protobuf v3 (stepancheg) generated types.
///
/// Generates `TypedValue`, `IntoValue`, `FromValue`, `From<T>` for `Value`,
/// and `TryFrom<Value>` implementations using protobuf v3 serialization.
///
/// # Requirements
///
/// The type must implement `protobuf::MessageFull`.
///
/// # Attributes
/// - `type_name = "..."`: Override the protobuf type name (default: from descriptor).
/// - `crate = ...`: Custom path to the cel_cxx crate.
///
/// # Setup
///
/// In your `build.rs`, inject the derive via `customize_callback()`:
///
/// ```rust,ignore
/// // build.rs
/// use protobuf::reflect::MessageDescriptor;
/// use protobuf_codegen::{Codegen, Customize, CustomizeCallback};
///
/// struct DeriveProtobufLegacyValue;
///
/// impl CustomizeCallback for DeriveProtobufLegacyValue {
/// fn message(&self, _message: &MessageDescriptor) -> Customize {
/// Customize::default().before("#[derive(::cel_cxx::ProtobufLegacyValue)]")
/// }
/// }
///
/// fn main() {
/// Codegen::new()
/// .cargo_out_dir("protos")
/// .input("proto/my.proto")
/// .include("proto/")
/// .customize_callback(DeriveProtobufLegacyValue)
/// .run_from_script();
/// }
/// ```
/// Derive macro for protobuf v4 (cpp kernel) types — **stub, not yet implemented**.
///
/// All generated methods will panic with `unimplemented!()`.
///
/// # Attributes
/// - `type_name = "..."`: **Required.** The fully-qualified protobuf type name.
/// - `crate = ...`: Custom path to the cel_cxx crate.