chaokunyang commented on issue #2717:
URL: https://github.com/apache/fory/issues/2717#issuecomment-3385100744

   Here is an example:
   ```rust
   pub struct WriteContext<'se> {
       pub writer: &'se mut Writer,
       meta_resolver: MetaWriterResolver<'se>,
       pub ref_writer: RefWriter,
   }
   pub struct ReadContext<'de, 'bf: 'de> {
       pub reader: Reader<'bf>,
       pub meta_resolver: MetaReaderResolver,
       pub ref_reader: RefReader,
       max_dyn_depth: u32,
       current_depth: u32,
   }
   ```
   
   Serializer:
   ```rust
   pub trait Serializer: 'static {
       /// Entry point of the serialization.
       fn fory_write(&self, fory: &Fory, context: &mut WriteContext, is_field: 
bool)
       where
           Self: Sized,
       {
           write_ref_info_data(self, fory: &Fory, context, is_field, false, 
false);
       }
   
       fn fory_read(context: fory: &Fory, &mut ReadContext, is_field: bool) -> 
Result<Self, Error>
       where
           Self: Sized + ForyDefault,
       {
           read_ref_info_data(fory, context, is_field, false, false)
       }
   
       fn fory_is_option() -> bool
       where
           Self: Sized,
       {
           false
       }
   
       fn fory_is_none(&self) -> bool {
           false
       }
   
       fn fory_is_polymorphic() -> bool
       where
           Self: Sized,
       {
           false
       }
   
       fn fory_is_shared_ref() -> bool
       where
           Self: Sized,
       {
           false
       }
   
       fn fory_get_type_id(fory: &Fory) -> u32
       where
           Self: Sized,
       {
           fory.get_type_resolver()
               .get_type_info(std::any::TypeId::of::<Self>())
               .get_type_id()
       }
   
       fn fory_type_id_dyn(&self, fory: &Fory) -> u32;
   
       /// The possible max memory size of the type.
       /// Used to reserve the buffer space to avoid reallocation, which may 
hurt performance.
       fn fory_reserved_space() -> usize
       where
           Self: Sized,
       {
           0
       }
   
       fn fory_write_type_info(fory: &Fory, context: &mut WriteContext, 
_is_field: bool)
       where
           Self: Sized,
       {
       }
   
       fn fory_read_type_info(fory: &Fory, context: &mut ReadContext, 
_is_field: bool)
       where
           Self: Sized,
       {
   
       }
   
       // only used by struct/enum/ext
       fn fory_read_compatible(fory: &Fory, context: &mut ReadContext) -> 
Result<Self, Error>
       where
           Self: Sized,
       {
   
       }
   
       /// Write/Read the data into the buffer. Need to be implemented.
       fn fory_write_data(&self,fory: &Fory,  context: &mut WriteContext, 
is_field: bool);
   
       fn fory_read_data(fory: &Fory, context: &mut ReadContext, is_field: 
bool) -> Result<Self, Error>
       where
           Self: Sized + ForyDefault;
   
       fn fory_concrete_type_id(&self) -> std::any::TypeId {
           std::any::TypeId::of::<Self>()
       }
   
       fn as_any(&self) -> &dyn Any;
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to