MCPcopy Create free account
hub / github.com/apache/fory / gen_read_single_payload

Function gen_read_single_payload

rust/fory-derive/src/object/derive_enum.rs:187–199  ·  view source on GitHub ↗
(source_fields: &[SourceField<'_>])

Source from the content-addressed store, hash-verified

185}
186
187fn gen_read_single_payload(source_fields: &[SourceField<'_>]) -> TokenStream {
188 match build_bindings(source_fields) {
189 Ok(bindings) => match bindings.as_slice() {
190 [FieldBinding::Codec(binding)] => binding
191 .read_with_mode_expr(quote! { fory_core::RefMode::Tracking }, quote! { true }),
192 [FieldBinding::Skipped(_)] => {
193 quote! { compile_error!("skip is not valid for union payload fields") }
194 }
195 _ => quote! { compile_error!("union payload helper requires exactly one field") },
196 },
197 Err(err) => err.to_compile_error(),
198 }
199}
200
201/// For Union-compatible enums with data variants, return UNION TypeId in xlang mode.
202pub fn gen_actual_type_id(data_enum: &DataEnum) -> TokenStream {

Callers 1

Calls 2

build_bindingsFunction · 0.85
read_with_mode_exprMethod · 0.80

Tested by

no test coverage detected