Skip to content

Commit

Permalink
Merge pull request #150 from antoine-de/id_for_raw_pathways
Browse files Browse the repository at this point in the history
Add pathways to the object type and implement id for rawpathways
  • Loading branch information
antoine-de authored Nov 29, 2023
2 parents 2449345 + 6cfaae2 commit 3906ff6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>", "Antoine Desbordes <[email protected]>"]
repository = "https://github.com/rust-transit/gtfs-structure"
license = "MIT"
Expand Down
2 changes: 2 additions & 0 deletions src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub enum ObjectType {
Shape,
/// [FareAttribute] <https://gtfs.org/reference/static/#fare_rulestxt>
Fare,
/// [Pathway] <https://gtfs.org/schedule/reference/#pathwaystxt>
Pathway,
}

/// Describes the kind of [Stop]. See <https://gtfs.org/reference/static/#stopstxt> `location_type`
Expand Down
18 changes: 18 additions & 0 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,18 @@ pub struct RawPathway {
pub reversed_signposted_as: Option<String>,
}

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 {
Expand Down Expand Up @@ -790,6 +802,12 @@ impl Id for Pathway {
}
}

impl Type for Pathway {
fn object_type(&self) -> ObjectType {
ObjectType::Pathway
}
}

impl From<RawPathway> for Pathway {
/// Converts from a [RawPathway] to a [Pathway]
fn from(raw: RawPathway) -> Self {
Expand Down

0 comments on commit 3906ff6

Please sign in to comment.