Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement hashing for many basic enums #164

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.41.2"
version = "0.41.3"
authors = ["Tristram Gräbener <[email protected]>", "Antoine Desbordes <[email protected]>"]
repository = "https://github.com/rust-transit/gtfs-structure"
license = "MIT"
Expand Down
20 changes: 10 additions & 10 deletions src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl Serialize for RouteType {
}

/// Describes if and how a traveller can board or alight the vehicle. See <https://gtfs.org/reference/static/#stop_timestxt> `pickup_type` and `dropoff_type`
#[derive(Debug, Derivative, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Derivative, Copy, Clone, PartialEq, Eq, Hash)]
#[derivative(Default(bound = ""))]
pub enum PickupDropOffType {
/// Regularly scheduled pickup or drop off (default when empty).
Expand Down Expand Up @@ -225,7 +225,7 @@ impl Serialize for PickupDropOffType {
/// Indicates whether a rider can board the transit vehicle anywhere along the vehicle’s travel path
///
/// Those values are only defined on <https://developers.google.com/transit/gtfs/reference#routestxt,> not on <https://gtfs.org/reference/static/#routestxt>
#[derive(Debug, Derivative, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Derivative, Copy, Clone, PartialEq, Eq, Hash)]
#[derivative(Default(bound = ""))]
pub enum ContinuousPickupDropOff {
/// Continuous stopping pickup or drop off.
Expand Down Expand Up @@ -281,7 +281,7 @@ impl<'de> Deserialize<'de> for ContinuousPickupDropOff {
}

/// Describes if the stop time is exact or not. See <https://gtfs.org/reference/static/#stop_timestxt> `timepoint`
#[derive(Debug, Derivative, Serialize, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Derivative, Serialize, Copy, Clone, PartialEq, Eq, Hash)]
#[derivative(Default)]
pub enum TimepointType {
/// Times are considered approximate
Expand Down Expand Up @@ -373,7 +373,7 @@ pub enum Exception {
}

/// Defines the direction of a [Trip], only for display, not for routing. See <https://gtfs.org/reference/static/#tripstxt> `direction_id`
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq, Eq, Hash)]
pub enum DirectionType {
/// Travel in one direction (e.g. outbound travel).
#[serde(rename = "0")]
Expand All @@ -384,7 +384,7 @@ pub enum DirectionType {
}

/// Is the [Trip] accessible with a bike. See <https://gtfs.org/reference/static/#tripstxt> `bikes_allowed`
#[derive(Debug, Derivative, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Derivative, Copy, Clone, PartialEq, Eq, Hash)]
#[derivative(Default())]
pub enum BikesAllowedType {
/// No bike information for the trip
Expand Down Expand Up @@ -447,7 +447,7 @@ pub enum PaymentMethod {
}

/// Defines if the [Frequency] is exact (the vehicle runs exactly every n minutes) or not
#[derive(Debug, Serialize, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Serialize, Copy, Clone, PartialEq, Eq, Hash)]
pub enum ExactTimes {
/// Frequency-based trips
FrequencyBased = 0,
Expand All @@ -474,7 +474,7 @@ impl<'de> Deserialize<'de> for ExactTimes {
}

/// Defines how many transfers can be done with on [FareAttribute]
#[derive(Debug, Derivative, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Derivative, Copy, Clone, PartialEq, Eq, Hash)]
#[derivative(Default(bound = ""))]
pub enum Transfers {
/// Unlimited transfers are permitted
Expand Down Expand Up @@ -521,7 +521,7 @@ impl Serialize for Transfers {
}
}
/// Defines the type of a [StopTransfer]
#[derive(Debug, Serialize, Derivative, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Serialize, Derivative, Copy, Clone, PartialEq, Eq, Hash)]
#[derivative(Default)]
pub enum TransferType {
/// Recommended transfer point between routes
Expand Down Expand Up @@ -569,7 +569,7 @@ impl<'de> Deserialize<'de> for TransferType {
}

/// Type of pathway between [from_stop] and [to_stop]
#[derive(Debug, Serialize, Deserialize, Derivative, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Serialize, Deserialize, Derivative, Copy, Clone, PartialEq, Eq, Hash)]
#[derivative(Default)]
pub enum PathwayMode {
/// A walkway
Expand Down Expand Up @@ -599,7 +599,7 @@ pub enum PathwayMode {
}

/// Indicates in which direction the pathway can be used
#[derive(Debug, Serialize, Deserialize, Derivative, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Serialize, Deserialize, Derivative, Copy, Clone, PartialEq, Eq, Hash)]
#[derivative(Default)]
pub enum PathwayDirectionType {
/// Unidirectional pathway, it can only be used from [from_stop_id] to [to_stop_id].
Expand Down
3 changes: 2 additions & 1 deletion src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use chrono::{Datelike, NaiveDate, Weekday};
use rgb::RGB8;

use std::fmt;
use std::hash::Hash;
use std::sync::Arc;

/// Objects that have an identifier implement this trait
Expand Down Expand Up @@ -33,7 +34,7 @@ impl<T: Type> Type for Arc<T> {
}

/// A calender describes on which days the vehicle runs. See <https://gtfs.org/reference/static/#calendartxt>
#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
pub struct Calendar {
/// Unique technical identifier (not for the traveller) of this calendar
#[serde(rename = "service_id")]
Expand Down
Loading