-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SpannedVisitor
field order
#789
Comments
When we controlled both sides, the order didn't matter and the current approach is much simpler to implement. In making this easier for when its easier to generate the values in a specific order, I think its best to generalize it for maximum compatibility. |
btw would anything from #635 be useful? It was blocked, pending feedback. |
I don't think it's useful for my particular use case with a streaming parser where the span and value are not known upfront. |
I'm attempting to implement span support for serde_yaml in a way compatible to serde_spanned. Specifically, I'd like to handle the magic struct in
deserialize_struct
from theDeserializerFromEvents
deserializer.DeserializerFromEvents
has apos
field that appear relevant, I'm trying detect the span based on this position cursor. However, due to the wayDeserializerFromEvents
works, it's impossible to extractend
of the span the before parsing the value.I thought about implementing
SpannedDeserializer
in a way that just wraps aroundself: &mut DeserializerFromEvents<'de, 'document>
, so it can first spit out the startingpos
, then thevalue
, then the endingpos
.However, based on how
SpannedVisitor
is implemented, it expect a strict order of keys to emit from my deserializer, which makes my plan unfeasible.Based on my understanding of how serde_spanned works, making
SpannedVisitor
consume the keys in order ofstart
>value
>end
(orvalue
>start
>end
) should make it flexible for use cases like mine. Or, for backward compatibility's sake, maybe it's better to allowSpannedVisitor
consume the keys in arbitrary order. Or perhaps I'm doing it wrong and there is a better way to do it?The text was updated successfully, but these errors were encountered: