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

Function write

rust/fory-core/src/serializer/struct_.rs:92–114  ·  view source on GitHub ↗
(
    this: &T,
    context: &mut WriteContext,
    ref_mode: RefMode,
    write_type_info: bool,
)

Source from the content-addressed store, hash-verified

90
91#[inline(always)]
92pub fn write<T: Serializer>(
93 this: &T,
94 context: &mut WriteContext,
95 ref_mode: RefMode,
96 write_type_info: bool,
97) -> Result<(), Error> {
98 match ref_mode {
99 RefMode::None => {}
100 RefMode::NullOnly => {
101 context.writer.write_i8(RefFlag::NotNullValue as i8);
102 }
103 RefMode::Tracking => {
104 // For ref tracking mode, write RefValue flag and reserve a ref_id
105 // so this struct participates in reference tracking.
106 context.writer.write_i8(RefFlag::RefValue as i8);
107 context.ref_writer.reserve_ref_id();
108 }
109 }
110 if write_type_info {
111 T::fory_write_type_info(context)?;
112 }
113 this.fory_write_data(context)
114}
115
116pub type BeforeWriteFieldFunc =
117 fn(struct_name: &str, field_name: &str, field_value: &dyn Any, context: &mut WriteContext);

Callers

nothing calls this directly

Calls 4

fory_write_type_infoFunction · 0.85
write_i8Method · 0.80
reserve_ref_idMethod · 0.45
fory_write_dataMethod · 0.45

Tested by

no test coverage detected