From 7878f3aea2972313c08c130c7801aad69369faad Mon Sep 17 00:00:00 2001 From: antoine-de Date: Wed, 29 Nov 2023 15:09:08 +0100 Subject: [PATCH 1/2] Add pathways to the object type and implement id for rawpathways This way pathways are handle like the rest of the objects --- src/enums.rs | 2 ++ src/objects.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/enums.rs b/src/enums.rs index 3541c6b..21befa8 100644 --- a/src/enums.rs +++ b/src/enums.rs @@ -18,6 +18,8 @@ pub enum ObjectType { Shape, /// [FareAttribute] Fare, + /// [Pathway] + Pathway, } /// Describes the kind of [Stop]. See `location_type` diff --git a/src/objects.rs b/src/objects.rs index 8ce826a..9c65582 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -757,6 +757,18 @@ pub struct RawPathway { pub reversed_signposted_as: Option, } +impl Id for RawPathway { + fn id(&self) -> &str { + &self.id + } +} + +impl Type for RawPathway { + fn object_type(&self) -> ObjectType { + ObjectType::Pathway + } +} + /// Pathway going from a stop to another. #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Pathway { @@ -790,6 +802,12 @@ impl Id for Pathway { } } +impl Type for Pathway { + fn object_type(&self) -> ObjectType { + ObjectType::Pathway + } +} + impl From for Pathway { /// Converts from a [RawPathway] to a [Pathway] fn from(raw: RawPathway) -> Self { From 6cfaae288bc49d59b094d4f6470c8a295c868132 Mon Sep 17 00:00:00 2001 From: antoine-de Date: Wed, 29 Nov 2023 15:11:41 +0100 Subject: [PATCH 2/2] update minor version as it is a breaking change to add a value to an enum --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 03f72dd..4876fe2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Read GTFS (public transit timetables) files" name = "gtfs-structures" -version = "0.37.1" +version = "0.38.0" authors = ["Tristram Gräbener ", "Antoine Desbordes "] repository = "https://github.com/rust-transit/gtfs-structure" license = "MIT"