pub struct NetRelation {
pub id: String,
pub from_netelement_id: String,
pub to_netelement_id: String,
pub position_on_a: u8,
pub position_on_b: u8,
pub navigable_forward: bool,
pub navigable_backward: bool,
}Expand description
Represents a navigability connection between two track segments
A NetRelation defines whether trains can travel from one netelement to another. Navigability may be unidirectional (e.g., one-way track) or bidirectional.
§Examples
use tp_lib_core::NetRelation;
// Bidirectional connection: trains can go from A to B and from B to A
let relation = NetRelation::new(
"NR001".to_string(),
"NE_A".to_string(),
"NE_B".to_string(),
1, // position_on_a: end of A
0, // position_on_b: start of B
true, // A → B allowed
true, // B → A allowed
)?;
assert!(relation.is_bidirectional());Fields§
§id: StringUnique identifier for this netrelation
from_netelement_id: StringID of the source netelement (starting track segment)
to_netelement_id: StringID of the target netelement (destination track segment)
position_on_a: u8Position on netelementA where the connection applies (0 = start, 1 = end)
position_on_b: u8Position on netelementB where the connection applies (0 = start, 1 = end)
Whether trains can navigate forward (from → to)
Whether trains can navigate backward (to → from)
Implementations§
Source§impl NetRelation
impl NetRelation
Sourcepub fn new(
id: String,
from_netelement_id: String,
to_netelement_id: String,
position_on_a: u8,
position_on_b: u8,
navigable_forward: bool,
navigable_backward: bool,
) -> Result<Self, ProjectionError>
pub fn new( id: String, from_netelement_id: String, to_netelement_id: String, position_on_a: u8, position_on_b: u8, navigable_forward: bool, navigable_backward: bool, ) -> Result<Self, ProjectionError>
Create a new netrelation with validation
Sourcepub fn validate(&self) -> Result<(), ProjectionError>
pub fn validate(&self) -> Result<(), ProjectionError>
Validate netrelation fields
Check if navigation is allowed in forward direction (from → to)
Check if navigation is allowed in backward direction (to → from)
Sourcepub fn is_bidirectional(&self) -> bool
pub fn is_bidirectional(&self) -> bool
Check if bidirectional (both directions navigable)
Trait Implementations§
Source§impl Clone for NetRelation
impl Clone for NetRelation
Source§fn clone(&self) -> NetRelation
fn clone(&self) -> NetRelation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NetRelation
impl Debug for NetRelation
Source§impl<'de> Deserialize<'de> for NetRelation
impl<'de> Deserialize<'de> for NetRelation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for NetRelation
impl PartialEq for NetRelation
Source§impl Serialize for NetRelation
impl Serialize for NetRelation
impl StructuralPartialEq for NetRelation
Auto Trait Implementations§
impl Freeze for NetRelation
impl RefUnwindSafe for NetRelation
impl Send for NetRelation
impl Sync for NetRelation
impl Unpin for NetRelation
impl UnsafeUnpin for NetRelation
impl UnwindSafe for NetRelation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more