Skip to content

Commit

Permalink
Make lookup key clonable, store language list
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Feb 5, 2024
1 parent f99961c commit ca77467
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/gtfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,11 @@ impl Gtfs {
if let Some(field) = Self::table_and_field_to_enum(row.table_name.as_str(), row.field_name.as_str()) {
if let Some(key) = Self::key_options_to_struct(row.record_id, row.record_sub_id, row.field_value) {
res.insert(TranslationLookup {
language: language_tag,
field: field,
language: language_tag.clone(),
field: field.clone(),
key: key
}, row.translation);
possible_translations.insert((field, language_tag));
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<T: Type> Type for Arc<T> {
}
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum TranslatableField {

Check warning on line 50 in src/objects.rs

View workflow job for this annotation

GitHub Actions / Test Suite

missing documentation for an enum
Agency(AgencyFields),
Areas(AreaFields),
Expand All @@ -59,14 +59,14 @@ pub enum TranslatableField {
Trips(TripFields),
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum TranslationKey {
Record(String),
RecordSub((String, String)),
Value(String),
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub struct TranslationLookup {
pub language: LanguageTag,
pub field: TranslatableField,
Expand All @@ -78,53 +78,53 @@ pub trait Translatable: Id {
fn field_value(&self, field: Self::Fields) -> &str;
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum StopTimeFields {
Headsign,
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum RouteFields {
Desc,
LongName,
ShortName,
Url,
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum CalendarFields {
ServiceId,
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum FeedInfoFields {
PublisherName,
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum AreaFields {
Name,
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum AgencyFields {
Name,
FareUrl,
Url,
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum FareProductsFields {
ProductName,
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum TripFields {
Headsign,
ShortName
}

#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Hash, Eq, PartialEq, Clone)]
pub enum StopFields {
Code,
Name,
Expand Down

0 comments on commit ca77467

Please sign in to comment.