pub struct Node<T: MapState> {
pub position: Position,
pub adjacent_nodes: RefCell<AdjacentNodes<T>>,
pub status: RefCell<NodeStatus<T>>,
}
Fields§
§position: Position
§adjacent_nodes: RefCell<AdjacentNodes<T>>
§status: RefCell<NodeStatus<T>>
Implementations§
source§impl Node<MapStateUninitialized>
impl Node<MapStateUninitialized>
pub fn new(position: Position) -> Self
pub fn set_train(&self, train: UnIntiTrainRef) -> Result<()>
sourcepub fn add_link(
&self,
to: UnIntiNodeRef,
direction: Direction,
max_speed: i8,
length: u32,
controller: SwitchControllerOption<MapStateUninitialized>
) -> Result<()>
pub fn add_link( &self, to: UnIntiNodeRef, direction: Direction, max_speed: i8, length: u32, controller: SwitchControllerOption<MapStateUninitialized> ) -> Result<()>
The nodes can be of two types:
- switch nodes
- non-switch nodes when a link is added it must follow a few rules:
- a non-switch node can have at most one link forward
- a non-switch node can have at most one link backward
- a switch node must have exactly two links forward, (one for each switch position)
- a switch node can have at most one link backward this function enforce all those rules, except the third one, which is enforced inside map_creation_view
pub fn get_next_available_direction(&self) -> Result<Direction>
Trait Implementations§
source§impl CompleteInitialization for Node<MapStateInitialized>
impl CompleteInitialization for Node<MapStateInitialized>
type InitFromType = Node<MapStateUninitialized>
fn complete_initialization( &self, init_from: &Self::InitFromType, map: &Map<MapStateInitialized> )
source§impl<'de, T> Deserialize<'de> for Node<T>where
T: Deserialize<'de> + MapState,
impl<'de, T> Deserialize<'de> for Node<T>where T: Deserialize<'de> + MapState,
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Initialize for Node<MapStateUninitialized>
impl Initialize for Node<MapStateUninitialized>
type InitializedType = Node<MapStateInitialized>
fn initialize(self) -> Self::InitializedType
source§impl Into<IntiNodeRef> for &Node<MapStateInitialized>
impl Into<IntiNodeRef> for &Node<MapStateInitialized>
source§fn into(self) -> IntiNodeRef
fn into(self) -> IntiNodeRef
Converts this type into the (usually inferred) input type.