chaokunyang opened a new issue, #2672:
URL: https://github.com/apache/fory/issues/2672
### Feature Request
Cureent Rust Serializer interface is not clean:
```rust
impl Serializer for bool {
fn reserved_space() -> usize {
mem::size_of::<i32>()
}
fn write(&self, context: &mut WriteContext, _is_field: bool) {
context.writer.u8(if *self { 1 } else { 0 });
}
fn write_type_info(context: &mut WriteContext, is_field: bool) {
if *context.get_fory().get_mode() == Mode::Compatible && !is_field {
context.writer.var_uint32(TypeId::BOOL as u32);
}
}
fn read(context: &mut ReadContext) -> Result<Self, Error> {
Ok(context.reader.u8() == 1)
}
fn read_type_info(context: &mut ReadContext, is_field: bool) {
if *context.get_fory().get_mode() == Mode::Compatible && !is_field {
let remote_type_id = context.reader.var_uint32();
assert_eq!(remote_type_id, TypeId::BOOL as u32);
}
}
fn get_type_id(_fory: &Fory) -> u32 {
TypeId::BOOL as u32
}
}
```
### Is your feature request related to a problem? Please describe
We should only have two methods:
```rust
impl Serializer for bool {
fn write(&self, context: &mut WriteContext, _is_field: bool) {
context.writer.u8(if *self { 1 } else { 0 });
}
fn read(context: &mut ReadContext) -> Result<Self, Error> {
Ok(context.reader.u8() == 1)
}
}
```
### Describe the solution you'd like
_No response_
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
--
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]