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

Function read

rust/fory-core/src/serializer/enum_.rs:75–100  ·  view source on GitHub ↗
(
    context: &mut ReadContext,
    ref_mode: RefMode,
    read_type_info: bool,
)

Source from the content-addressed store, hash-verified

73
74#[inline(always)]
75pub fn read<T: Serializer + ForyDefault>(
76 context: &mut ReadContext,
77 ref_mode: RefMode,
78 read_type_info: bool,
79) -> Result<T, Error> {
80 let ref_flag = if ref_mode != RefMode::None {
81 context.reader.read_i8()?
82 } else {
83 RefFlag::NotNullValue as i8
84 };
85 if ref_flag == RefFlag::Null as i8 {
86 Ok(T::fory_default())
87 } else if ref_flag == (RefFlag::NotNullValue as i8) || ref_flag == (RefFlag::RefValue as i8) {
88 if read_type_info {
89 T::fory_read_type_info(context)?;
90 }
91 T::fory_read_data(context)
92 } else if ref_flag == (RefFlag::Ref as i8) {
93 Err(Error::invalid_ref("Invalid ref, enum type is not a ref"))
94 } else {
95 Err(Error::invalid_data(format!(
96 "Unknown ref flag: {}",
97 ref_flag
98 )))
99 }
100}
101
102#[inline(always)]
103pub fn read_type_info<T: Serializer>(context: &mut ReadContext) -> Result<(), Error> {

Callers 15

fory_read_dataFunction · 0.70
assume_array_initFunction · 0.70
read_complex_arrayFunction · 0.70
fory_defaultMethod · 0.70
read_with_type_infoMethod · 0.50
read_with_type_infoMethod · 0.50
read_with_type_infoMethod · 0.50
read_with_type_infoMethod · 0.50
read_with_type_infoMethod · 0.50

Calls 3

fory_read_type_infoFunction · 0.85
fory_read_dataFunction · 0.85
read_i8Method · 0.80

Tested by 15

read_with_type_infoMethod · 0.40
test_bufferFunction · 0.40
test_buffer_varFunction · 0.40
test_murmurhash3Function · 0.40
test_string_serializerFunction · 0.40
test_simple_structFunction · 0.40
test_named_simple_structFunction · 0.40
test_listFunction · 0.40