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

Function build_bindings

rust/fory-derive/src/object/field_codec.rs:404–437  ·  view source on GitHub ↗
(
    source_fields: &'a [SourceField<'a>],
)

Source from the content-addressed store, hash-verified

402}
403
404pub(crate) fn build_bindings<'a>(
405 source_fields: &'a [SourceField<'a>],
406) -> syn::Result<Vec<FieldBinding<'a>>> {
407 source_fields
408 .iter()
409 .map(|source| {
410 let meta = parse_field_meta(source.field)?;
411 let private_ident = create_private_field_name(source.field, source.original_index);
412 if meta.skip {
413 return Ok(FieldBinding::Skipped(SkippedField {
414 source,
415 private_ident,
416 }));
417 }
418 let type_class = classify_field_type(&source.field.ty);
419 let is_outer_option = is_option_type(&source.field.ty);
420 let nullable = meta.effective_nullable(type_class) || is_outer_option;
421 let track_ref = meta.effective_ref(type_class);
422 let field_id = if meta.uses_tag_id() {
423 meta.effective_id() as i16
424 } else {
425 -1
426 };
427 let dispatch = field_dispatch_for(&source.field.ty, &meta, nullable, track_ref)?;
428 Ok(FieldBinding::Codec(ResolvedField {
429 source,
430 private_ident,
431 dispatch,
432 value_ty: &source.field.ty,
433 field_id,
434 }))
435 })
436 .collect()
437}
438
439fn field_dispatch_for(
440 ty: &Type,

Callers 14

declare_varFunction · 0.85
assign_valueFunction · 0.85
gen_write_variant_fieldsFunction · 0.85
gen_write_single_payloadFunction · 0.85
gen_read_variant_fieldsFunction · 0.85
gen_read_single_payloadFunction · 0.85
gen_reserved_spaceFunction · 0.85

Calls 11

parse_field_metaFunction · 0.85
classify_field_typeFunction · 0.85
is_option_typeFunction · 0.85
field_dispatch_forFunction · 0.85
CodecInterface · 0.85
effective_nullableMethod · 0.80
effective_refMethod · 0.80
effective_idMethod · 0.80
mapMethod · 0.45
uses_tag_idMethod · 0.45

Tested by

no test coverage detected