(source_fields: &[SourceField<'_>])
| 185 | } |
| 186 | |
| 187 | fn 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. |
| 202 | pub fn gen_actual_type_id(data_enum: &DataEnum) -> TokenStream { |
no test coverage detected