Joey9801 / igc-rs

MIT License
6 stars 4 forks source link

IGC file writer #6

Closed Turbo87 closed 5 years ago

Turbo87 commented 5 years ago

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

Joey9801 commented 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 :)

Turbo87 commented 5 years ago

@estk do you want to look into that?

Joey9801 commented 5 years ago

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.

Turbo87 commented 5 years ago

yep, although I'm wondering if the formatters should return Result to in case of invalid values 🤔

estk commented 5 years ago

@Turbo87 @Joey9801 I'd be happy to look into this, might be a few weeks though.

Joey9801 commented 5 years ago

@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.

Turbo87 commented 5 years ago

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?

Joey9801 commented 5 years ago

Implemented in #15