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

Function skip_value

rust/fory-core/src/serializer/skip.rs:458–839  ·  view source on GitHub ↗
(
    context: &mut ReadContext,
    field_type: &FieldType,
    read_ref_flag: bool,
    _is_field: bool,
    type_info: &Option<Rc<crate::TypeInfo>>,
)

Source from the content-addressed store, hash-verified

456#[inline(never)]
457#[allow(unreachable_code)]
458fn skip_value(
459 context: &mut ReadContext,
460 field_type: &FieldType,
461 read_ref_flag: bool,
462 _is_field: bool,
463 type_info: &Option<Rc<crate::TypeInfo>>,
464) -> Result<(), Error> {
465 if read_ref_flag {
466 let ref_flag = context.reader.read_i8()?;
467 if ref_flag == (RefFlag::Null as i8) {
468 return Ok(());
469 }
470 if ref_flag == (RefFlag::Ref as i8) {
471 // Reference to already-seen object, skip the reference index
472 let _ref_index = context.reader.read_var_u32()?;
473 return Ok(());
474 }
475 // RefValue (0) or NotNullValue (-1) means we need to read the actual object
476 }
477 let type_id_num = field_type.type_id;
478
479 if type_id_num == types::UNKNOWN {
480 return skip_any_value(context, false);
481 }
482
483 // Handle user-defined types (struct/enum/ext/union)
484 if types::is_user_type(type_id_num) {
485 if type_id_num == types::COMPATIBLE_STRUCT
486 || type_id_num == types::STRUCT
487 || type_id_num == types::NAMED_STRUCT
488 || type_id_num == types::NAMED_COMPATIBLE_STRUCT
489 {
490 return skip_struct(context, type_id_num, type_info);
491 } else if type_id_num == types::ENUM || type_id_num == types::NAMED_ENUM {
492 let _ordinal = context.reader.read_var_u32()?;
493 return Ok(());
494 } else if type_id_num == types::UNION
495 || type_id_num == types::TYPED_UNION
496 || type_id_num == types::NAMED_UNION
497 {
498 let _ordinal = context.reader.read_var_u32()?;
499 return skip_any_value(context, true);
500 } else if type_id_num == types::EXT || type_id_num == types::NAMED_EXT {
501 return skip_ext(context, type_id_num, type_info);
502 } else {
503 return Err(Error::type_error(format!(
504 "Unknown type id: {} (type_info provided: {})",
505 type_id_num,
506 type_info.is_some()
507 )));
508 }
509 }
510
511 // Match on built-in types (ordered by TypeId enum values)
512 match type_id_num {
513 // ============ UNKNOWN ============
514 types::UNKNOWN => {
515 // UNKNOWN is used for polymorphic types in cross-language serialization

Callers 5

skip_field_valueFunction · 0.85
skip_any_valueFunction · 0.85
skip_collectionFunction · 0.85
skip_mapFunction · 0.85
skip_structFunction · 0.85

Calls 15

skip_any_valueFunction · 0.85
skip_collectionFunction · 0.85
skip_decimalFunction · 0.85
skip_sized_bytesFunction · 0.85
SomeFunction · 0.85
read_i8Method · 0.80
read_var_u32Method · 0.80
read_u8Method · 0.80
read_i16Method · 0.80
read_i32Method · 0.80
read_var_i32Method · 0.80
read_i64Method · 0.80

Tested by

no test coverage detected