Closed Turbo87 closed 5 years ago
I hadn't thought of that yet, but you're right that it would be fairly straightforward to add. I'm happy to do so, though feel free to open a PR :)
@estk do you want to look into that?
On further thought, implementing formatters for the various record types will actually help with adding property testing, as it enables property tests of the form format!("{}", rec).parse::<Record>() == rec
.
yep, although I'm wondering if the formatters should return Result to in case of invalid values 🤔
@Turbo87 @Joey9801 I'd be happy to look into this, might be a few weeks though.
@Turbo87 - I think it's more idiomatic to make it impossible to create invalid record structs - every sane instance of a record struct has a single well defined string representation.
@estk - I started having a look at implementing this over the weekend, I have just opened a WIP PR (#15) to track it.
I think it's more idiomatic to make it impossible to create invalid record structs - every sane instance of a record struct has a single well defined string representation.
yeah, that makes sense to me. just wondering how to implement that. are you thinking about a builder pattern kind of thing?
Implemented in #15
While the README claims that this is only a parser, the low-level nature of the structs seems to make it relatively straight-forward to implement writers for them too. Have you thought about that yet, or is that out-of-scope for this crate?
I'm asking because of the discussion in https://github.com/Turbo87/ogn-web-gateway/issues/11