token_parser: unify parsing and serialization

This reduces the number of things we have to update in our token parser
and serializer. For payloads, we we have to handle the payload cases
different, but we now have a structure that can deal with that
efficiently.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin committed 2025-02-04 08:08:08 -08:00
1 parent 005ecd740d
commit 61b3a92792
2 files changed
+48 -43

No files matched your search

@@ -146,6 +146,7 @@ pub trait TokenSerializable: Sized {
/// Return a list of serialization plans for a type. We do this for
/// type safety and assume constructing these types are lightweight
fn parse<'a>(parser: &mut TokenParser<'a>) -> Result<Self, ParseError<'a>>;
fn serialize(&self, write_token: fn(&str) -> Result<(), std::io::Error>) -> Result<(), std::io::Error>;
}
#[cfg(test)]