pub trait RailwayObject: Debug + Any {
    // Required methods
    fn id(&self) -> RailwayObjectId;
    fn position(&self) -> Option<NodeId>;
    fn set_position(&mut self, position: Option<NodeId>);
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
}
Expand description

The RailwayObject trait represents the basic properties of a railway object, including a unique identifier and a position within an internal model. Objects implementing this trait can be used in a railway simulation.

Required Methods§

source

fn id(&self) -> RailwayObjectId

Returns the unique identifier of the railway object.

Returns

A RailwayObjectId representing the unique identifier of the railway object.

source

fn position(&self) -> Option<NodeId>

Returns the position of the railway object within the internal model.

Returns

An Option<NodeId> representing the position of the railway object in the internal model. Returns None if the object has no position.

source

fn set_position(&mut self, position: Option<NodeId>)

Sets the position of the railway object within the internal model.

Arguments
  • position - An Option<NodeId> representing the new position of the railway object in the internal model. Pass None to remove the object’s position.
source

fn as_any(&self) -> &dyn Any

Returns a reference to the Any trait for this object.

This method is useful for downcasting the object to a concrete type when working with trait objects.

Returns

A reference to the Any trait for the object.

source

fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to the Any trait for this object.

This method is useful for downcasting the object to a concrete type when working with trait objects.

Returns

A mutable reference to the Any trait for the object.

Implementors§

source§

impl RailwayObject for Train

Implements the RailwayObject trait for the Train struct.