Currently to feed values into the sink one invokes the necessary type methods. So to feed a u64 one calls the u64 method etc.
This is quite convenient for implementing basic sinks as the default error handling kicks in for non implemented types. Additionally if a future type is added to the object model the sink just applies the default logic.
The downside however of this is that any sink that forwards operations to another sink needs to implement all methods and manually forward this. A hypothetically alternative method would involve values that do not require recursion to be passed directly. This might look like this:
struct NullIgnoringSink<'a> {
sink: SinkHandle<'a>,
}
impl<'a> Sink for NullIgnoringSink<'a> {
fn atom(&mut self, value: Atom, state: &DeserializerState) -> Result<(), Error> {
match value {
Atom::Null => Ok(()),
other => self.sink.atom(other, state),
}
}
}
Currently to feed values into the sink one invokes the necessary type methods. So to feed a
u64
one calls theu64
method etc.This is quite convenient for implementing basic sinks as the default error handling kicks in for non implemented types. Additionally if a future type is added to the object model the sink just applies the default logic.
The downside however of this is that any sink that forwards operations to another sink needs to implement all methods and manually forward this. A hypothetically alternative method would involve values that do not require recursion to be passed directly. This might look like this: