summaryrefslogtreecommitdiff
path: root/src/onboard
diff options
context:
space:
mode:
Diffstat (limited to 'src/onboard')
-rw-r--r--src/onboard/iceportal.rs12
-rw-r--r--src/onboard/mod.rs5
-rw-r--r--src/onboard/zugportal.rs8
3 files changed, 12 insertions, 13 deletions
diff --git a/src/onboard/iceportal.rs b/src/onboard/iceportal.rs
index bc97261..bde0b1f 100644
--- a/src/onboard/iceportal.rs
+++ b/src/onboard/iceportal.rs
@@ -8,12 +8,14 @@ use crate::onboard;
use crate::onboard::{OnBoardAPI, OnBoardInfo};
use crate::{serde::*, traits::*, travelynx::TrainRef};
+use crate::types::Trip;
+
pub struct Iceportal {}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct TripInfo {
- trip: Trip,
+ trip: IceTrip,
connection: Option<Value>,
selected_route: Option<Value>,
active: Option<Value>
@@ -21,7 +23,7 @@ pub struct TripInfo {
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
-struct Trip {
+struct IceTrip {
train_type: String,
vzn: String, // train number
// some position info here
@@ -100,10 +102,8 @@ impl OnBoardInfo for TripInfo {
}
}
- fn stops<'a>(
- &'a self
- ) -> Box<dyn std::iter::Iterator<Item = &'a dyn IsStation> + 'a> {
- Box::new(self.trip.stops.iter().map(|s| s as &dyn IsStation))
+ fn stops<'a>(&'a self) -> Trip<'a> {
+ (&self.trip.stops).into()
}
}
diff --git a/src/onboard/mod.rs b/src/onboard/mod.rs
index 56bd144..b6717e8 100644
--- a/src/onboard/mod.rs
+++ b/src/onboard/mod.rs
@@ -1,5 +1,6 @@
use crate::traits::IsStation;
use crate::travelynx::TrainRef;
+use crate::types::Trip;
use serde::de::DeserializeOwned;
pub mod iceportal;
@@ -47,9 +48,7 @@ pub trait OnBoardInfo {
fn get_train_ref(&self) -> TrainRef;
- fn stops<'a>(
- &'a self
- ) -> Box<dyn std::iter::Iterator<Item = &'a dyn IsStation> + 'a>;
+ fn stops<'a>(&'a self) -> Trip<'a>;
}
fn get_request<R>(uri: &str) -> Result<R, (serde_json::Error, String)>
diff --git a/src/onboard/zugportal.rs b/src/onboard/zugportal.rs
index 0ad6cfd..c649107 100644
--- a/src/onboard/zugportal.rs
+++ b/src/onboard/zugportal.rs
@@ -7,6 +7,8 @@ use crate::onboard;
use crate::onboard::{OnBoardAPI, OnBoardInfo};
use crate::{traits::*, travelynx::TrainRef};
+use crate::types::Trip;
+
pub struct Zugportal {}
#[derive(Deserialize, Debug)]
@@ -88,10 +90,8 @@ impl OnBoardInfo for Journey {
}
}
- fn stops<'a>(
- &'a self
- ) -> Box<dyn std::iter::Iterator<Item = &'a dyn IsStation> + 'a> {
- Box::new(self.stops.iter().map(|s| s as &dyn IsStation))
+ fn stops<'a>(&'a self) -> Trip<'a> {
+ (&self.stops).into()
}
}