Skip to content

Commit

Permalink
editoast: move ApplicableDirections to editoast_schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
hamz2a committed Apr 12, 2024
1 parent c2516ce commit 65f6747
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 15 deletions.
2 changes: 2 additions & 0 deletions editoast/editoast_schemas/src/infra.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
mod applicable_directions;
mod direction;
mod directional_track_range;
mod track_location;
mod track_offset;
mod track_range;
mod waypoint;

pub use applicable_directions::ApplicableDirections;
pub use direction::Direction;
pub use directional_track_range::DirectionalTrackRange;
pub use track_location::TrackLocation;
Expand Down
13 changes: 13 additions & 0 deletions editoast/editoast_schemas/src/infra/applicable_directions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use derivative::Derivative;
use serde::Deserialize;
use serde::Serialize;

#[derive(Debug, Derivative, Copy, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[derivative(Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ApplicableDirections {
StartToStop,
StopToStart,
#[derivative(Default)]
Both,
}
1 change: 1 addition & 0 deletions editoast/src/converters/osm_to_railjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub fn parse_osm(osm_pbf_in: PathBuf) -> Result<RailJson, Box<dyn Error + Send +

#[cfg(test)]
mod tests {
use editoast_schemas::infra::ApplicableDirections;
use std::collections::HashMap;

use super::parse_osm;
Expand Down
1 change: 1 addition & 0 deletions editoast/src/converters/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use editoast_schemas::infra::ApplicableDirections;
use editoast_schemas::infra::Direction;
use std::collections::HashMap;
use std::str::FromStr;
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/generated_data/error/speed_sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::generated_data::error::ObjectErrorGenerator;
use crate::infra_cache::Graph;
use crate::infra_cache::InfraCache;
use crate::infra_cache::ObjectCache;
use crate::schema::ApplicableDirections;
use crate::schema::InfraError;
use editoast_schemas::infra::ApplicableDirections;
use editoast_schemas::infra::Direction;
use editoast_schemas::primitives::OSRDIdentified;
use editoast_schemas::primitives::ObjectRef;
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/infra_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,6 @@ pub mod tests {
use crate::infra_cache::SwitchCache;
use crate::map::BoundingBox;
use crate::modelsv2::infra::tests::test_infra_transaction;
use crate::schema::ApplicableDirections;
use crate::schema::ApplicableDirectionsTrackRange;
use crate::schema::Electrification;
use crate::schema::Endpoint;
Expand All @@ -763,6 +762,7 @@ pub mod tests {
use crate::schema::TrackEndpoint;
use editoast_common::Identifier;
use editoast_common::NonBlankString;
use editoast_schemas::infra::ApplicableDirections;
use editoast_schemas::infra::Direction;
use editoast_schemas::primitives::OSRDIdentified;

Expand Down
11 changes: 1 addition & 10 deletions editoast/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub use buffer_stop::BufferStop;
pub use buffer_stop::BufferStopCache;
pub use detector::Detector;
pub use detector::DetectorCache;
use editoast_schemas::infra::ApplicableDirections;
use editoast_schemas::infra::Direction;
use editoast_schemas::primitives::OSRDIdentified;
use editoast_schemas::primitives::ObjectType;
Expand Down Expand Up @@ -104,16 +105,6 @@ impl ApplicableDirectionsTrackRange {
}
}

#[derive(Debug, Derivative, Copy, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[derivative(Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ApplicableDirections {
StartToStop,
StopToStart,
#[derivative(Default)]
Both,
}

#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "UPPERCASE")]
pub enum Endpoint {
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/views/infra/auto_fixes/electrifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ mod tests {
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::operation::Operation;
use crate::infra_cache::ObjectCache;
use crate::schema::ApplicableDirections;
use crate::schema::ApplicableDirectionsTrackRange;
use crate::schema::Electrification;
use crate::schema::InfraError;
use editoast_common::Identifier;
use editoast_schemas::infra::ApplicableDirections;
use editoast_schemas::primitives::OSRDObject as _;
use editoast_schemas::primitives::ObjectRef;
use editoast_schemas::primitives::ObjectType;
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/views/infra/auto_fixes/speed_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ mod tests {
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::operation::Operation;
use crate::infra_cache::ObjectCache;
use crate::schema::ApplicableDirections;
use crate::schema::ApplicableDirectionsTrackRange;
use crate::schema::InfraError;
use crate::schema::SpeedSection;
use editoast_common::Identifier;
use editoast_schemas::infra::ApplicableDirections;
use editoast_schemas::primitives::OSRDObject as _;
use editoast_schemas::primitives::ObjectRef;
use editoast_schemas::primitives::ObjectType;
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/views/pathfinding/electrifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ pub mod tests {
use crate::models::pathfinding::tests::simple_pathfinding_fixture;
use crate::modelsv2::prelude::*;
use crate::modelsv2::ElectrificationModel;
use crate::schema::ApplicableDirections;
use crate::schema::ApplicableDirectionsTrackRange;
use crate::schema::Electrification as ElectrificationSchema;
use crate::views::tests::create_test_service;
use editoast_schemas::infra::ApplicableDirections;

#[fixture]
fn simple_mode_map() -> TrackMap<String> {
Expand Down

0 comments on commit 65f6747

Please sign in to comment.