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

Method read_compatible_direct

rust/fory-derive/src/object/field_codec.rs:231–266  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

229 }
230
231 pub fn read_compatible_direct(&self) -> TokenStream {
232 let var = &self.private_ident;
233 match &self.dispatch {
234 FieldDispatch::Codec { .. } => {
235 let call = self.codec_call();
236 quote! {
237 #var = #call::read_field(context)?;
238 }
239 }
240 FieldDispatch::Serializer { .. } => {
241 let ty = self.value_ty;
242 if serializer_field_can_use_data_path(self.source.field) {
243 quote! {
244 #var = <#ty as fory_core::Serializer>::fory_read_data(context)?;
245 }
246 } else {
247 quote! {
248 let read_ref_mode =
249 fory_core::serializer::codec::field_ref_mode(local_field_type);
250 let read_type_info = if context.is_compatible() {
251 fory_core::serializer::util::field_need_read_type_info(
252 local_field_type.type_id
253 )
254 } else {
255 <#ty as fory_core::Serializer>::fory_is_polymorphic()
256 };
257 #var = <#ty as fory_core::Serializer>::fory_read(
258 context,
259 read_ref_mode,
260 read_type_info,
261 )?;
262 }
263 }
264 }
265 }
266 }
267
268 pub fn direct_needs_local_field_type(&self) -> bool {
269 match &self.dispatch {

Callers 1

Calls 2

codec_callMethod · 0.80

Tested by

no test coverage detected