Skip to content

Commit

Permalink
Add pathways to the object type and implement id for rawpathways
Browse files Browse the repository at this point in the history
This way pathways are handle like the rest of the objects
  • Loading branch information
antoine-de committed Nov 29, 2023
1 parent 2449345 commit 7878f3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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 7878f3a

Please sign in to comment.