jdarais commented on PR #227:
URL: https://github.com/apache/avro-rs/pull/227#issuecomment-3121254182

   Ah, those are some good points...
   
   > Supporting skip is OK.
   > But what to do with skip_serializing and skip_deserialing ?! We will need 
to have a field for such fields in the Avro Schema but Serde does not call 
skip_field() when skip_serializing is used ...
   > 
   
   I think `skip_serializing` and `skip_deserializing` are also doable.  Since 
the Serializer is the one with the schema, the schema is decoupled from the 
struct implementing `Serialize`, so you just have to make sure that the schema 
you use to serialize doesn't include the field with the `skip_serializing` 
attribute.  (Of course, reading the value back would require a different schema 
that includes the field :slightly_frowning_face: but it is doable with 
different read and write schemas.  If you use `skip_serializing` but not 
`skip_deserializing`, then maybe that's just what you're signing yourself up 
for.)
   
   `skip_deserializing` should work more easily, since if we first read the 
value into an avro `Value` using the schema, then when we convert from `Value` 
to the struct using the `de.rs` implementation, it should be fine to ignore the 
value since doing so won't cause issues with parsing the rest of the record in 
the same way that ignoring a field does when serializing.
   
   > skip_field does not provide the value, so we use the default from the Avro 
Schema. This might need some more work! At the moment it is treated as an 
Option but probably it should be unpacked.
   
   Ah, that's a very good point.  That's a bummer that the value isn't provided 
in `skip_field`.  Yeah, if the default value is `None` (meaning no default 
value was specified) then we're kind of stuck, since there's no way to know 
what should go in that field.  Might be good to just return an `Err` in that 
case.


-- 
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]

Reply via email to