summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs2
-rw-r--r--src/onboard/iceportal.rs4
-rw-r--r--src/onboard/zugportal.rs4
-rw-r--r--src/traits.rs4
-rw-r--r--src/types.rs10
5 files changed, 12 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index 0a8fc54..7327785 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -188,7 +188,7 @@ async fn main() -> Result<(), ureq::Error> {
&format!("{}/api/v1/travel", cli.baseurl),
Action::CheckIn {
train: train.into(),
- to_station: status.to_station.map(|s| s.ds100),
+ to_station: status.to_station.map(|s| s.ds100).flatten(),
token: config.token_travel,
comment: None,
from_station: from
diff --git a/src/onboard/iceportal.rs b/src/onboard/iceportal.rs
index bde0b1f..55b35e7 100644
--- a/src/onboard/iceportal.rs
+++ b/src/onboard/iceportal.rs
@@ -75,8 +75,8 @@ impl IsStation for Stop {
self.timetable.scheduled_arrival_time.as_ref()
}
- fn ds100(&self) -> &str {
- "??"
+ fn ds100(&self) -> Option<&str> {
+ None
}
}
diff --git a/src/onboard/zugportal.rs b/src/onboard/zugportal.rs
index c649107..fe083ef 100644
--- a/src/onboard/zugportal.rs
+++ b/src/onboard/zugportal.rs
@@ -67,8 +67,8 @@ impl IsStation for Stop {
self.arrival_time.as_ref().map(|t| &t.predicted)
}
- fn ds100(&self) -> &str {
- "??"
+ fn ds100(&self) -> Option<&str> {
+ None
}
}
diff --git a/src/traits.rs b/src/traits.rs
index 091709a..b4b74e7 100644
--- a/src/traits.rs
+++ b/src/traits.rs
@@ -6,7 +6,7 @@ pub trait IsStation {
fn name(&self) -> &str;
fn scheduled_arrival(&self) -> Option<&DateTime<Utc>>;
fn real_arrival(&self) -> Option<&DateTime<Utc>>;
- fn ds100(&self) -> &str;
+ fn ds100(&self) -> Option<&str>;
fn to_fancy_string(&self) -> String {
// travelynx literally sends this entire precise date in case of an
@@ -35,7 +35,7 @@ pub trait IsStation {
text.green()
}
},
- self.ds100().red(),
+ self.ds100().unwrap_or("??").red(),
self.name()
)
}
diff --git a/src/types.rs b/src/types.rs
index 257f857..b698898 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -10,7 +10,7 @@ use crate::traits::IsStation;
#[serde(rename_all = "camelCase")]
pub struct Station {
name: String,
- pub ds100: String,
+ pub ds100: Option<String>,
uic: u64,
latitude: f64,
longitude: f64,
@@ -56,8 +56,8 @@ impl IsStation for Station {
Some(&self.real_time)
}
- fn ds100(&self) -> &str {
- &self.ds100
+ fn ds100(&self) -> Option<&str> {
+ self.ds100.as_deref()
}
}
@@ -72,8 +72,8 @@ impl IsStation for Stop {
self.real_arrival.as_ref()
}
- fn ds100(&self) -> &str {
- "[??]"
+ fn ds100(&self) -> Option<&str> {
+ None
}
}