feat: make Gtfs and RawGtfs structs clonable#181
feat: make Gtfs and RawGtfs structs clonable#181HelloJowet wants to merge 2 commits intorust-transit:mainfrom
Conversation
|
Hello, thank you for the pull request. This would however require some thoughts. Not making it clonable was a design choice: the GTFS data can be quite large, and cloning would immediately double the memory usage, and we put some efforts to keep it moderately controled. Maybe that function could also be renamed to store more the idea of a pipeline of treaments, it already does two unrelated things (metadata, validation) and could do the extra step you are planing? |
|
@Tristramg Thanks for your response.
I definitely agree with this approach. If we can solve my use case without cloning the
I’m not sure if a
To be honest, I’m also not super happy with how validate_and_metadata is currently designed. You’re right - it’s doing two separate things. I thought about implementing the
The GTFS reading and validation is just one phase of the project I'm working on. I'm almost finished with a converter from GTFS csv files into a SQLite database and I'm planning to create a GTFS to NeTEx converter too. I’m very much open to making this work open source once it's more mature. For now, the current solution of making the |
|
Ok, I’ll have a look if it’s easy to protect the clone with a feature flag (as it is a derived, right now I’m not sure how it would work). How urgent is it? For information, there is this converter that was built for transport.data.gouv.fr to convert gtfs to netex: https://github.com/hove-io/transit_model/blob/master/gtfs2netexfr/README.md |
#[derive(Debug)]
#[cfg_attr(feature = "clone", derive(Clone))]
pub struct RawGtfs {Ok, that was easier than I thought. Would it be OK for you to hide the clone ability behind a feature flag to avoid cloning by accident? @antoine-de do you have an opinion on this? |
|
hum, maybe we could change the validator and make it return (optionally?) the built it seems it need the ownership to be able to do validations on a Wouldn't it solve all your problems if it was possible to get back the whole GTFS at the end? |
Added Deserialize trait to ObjectType enum for GTFS.
I wan't to be able to clone the
GtfsandRawGtfsstructs.I need this, because the validate_and_metadata function in the transport-validator repo takes ownership of a
RawGtfsinstance. By making these structs clonable, I can perform additional tasks in my program after validation without having to read the GTFS feed from the source twice.