Skip to content

Commit

Permalink
💚 chore: default impl
Browse files Browse the repository at this point in the history
  • Loading branch information
zeon256 committed Jan 28, 2024
1 parent 10648b9 commit 7bf6de6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lta_models"
version = "0.6.0"
authors = ["budinverse <[email protected]>"]
authors = ["zeon256 <[email protected]>"]
edition = "2021"
license = "MIT"
description = "🚍Models for lta-rs"
Expand Down
28 changes: 8 additions & 20 deletions src/bus_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub enum Operator {
/// DD -> Double Decker
///
/// BD -> Bendy
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Default)]
#[serde(rename_all = "PascalCase")]
pub enum BusType {
#[serde(rename = "SD")]
Expand All @@ -49,22 +49,17 @@ pub enum BusType {
#[serde(rename = "BD")]
Bendy,

#[default]
#[serde(other)]
Unknown,
}

impl Default for BusType {
fn default() -> Self {
BusType::Unknown
}
}

/// SEA -> Seats available
///
/// SDA -> Standing available
///
/// LSD -> Limited standing
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Default)]
pub enum BusLoad {
#[serde(rename = "SEA")]
SeatsAvailable,
Expand All @@ -75,32 +70,24 @@ pub enum BusLoad {
#[serde(rename = "LSD")]
LimitedStanding,

#[default]
#[serde(other)]
Unknown,
}

impl Default for BusLoad {
fn default() -> Self {
BusLoad::Unknown
}
}

#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Default)]
pub enum BusFeature {
#[serde(rename = "WAB")]
WheelChairAccessible,

#[default]
#[serde(other)]
Unknown,
}

impl Default for BusFeature {
fn default() -> Self {
BusFeature::Unknown
}
}

#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Default)]
pub enum BusCategory {
#[serde(alias = "EXPRESS")]
Express,
Expand Down Expand Up @@ -132,6 +119,7 @@ pub enum BusCategory {
#[serde(alias = "FLAT FARE $2.00")]
FlatFareTwoDollar,

#[default]
#[serde(other)]
Unknown,
}
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! Data Structures for lta-rs and for LTA datamall APIs
// Forbid warnings in release builds:
#![forbid(unsafe_code)]
#![cfg_attr(not(debug_assertions), deny(warnings))]
#![warn(
clippy::all,
clippy::linkedlist,
clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
Expand All @@ -26,7 +28,6 @@
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value,
clippy::let_unit_value,
clippy::linkedlist,
clippy::lossy_float_literal,
clippy::macro_use_imports,
clippy::manual_ok_or,
Expand Down
4 changes: 3 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ pub mod de {
write!(f, "StringWrapErr")
}
}


/// # Errors
/// Fails when data cant be deserialized to String
pub fn treat_error_as_none<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
where
T: Deserialize<'de>,
Expand Down

0 comments on commit 7bf6de6

Please sign in to comment.