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§
sourcefn id(&self) -> RailwayObjectId
fn id(&self) -> RailwayObjectId
Returns the unique identifier of the railway object.
Returns
A RailwayObjectId representing the unique identifier of the railway object.
sourcefn position(&self) -> Option<NodeId>
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.
sourcefn set_position(&mut self, position: Option<NodeId>)
fn set_position(&mut self, position: Option<NodeId>)
Sets the position of the railway object within the internal model.
Arguments
position- AnOption<NodeId>representing the new position of the railway object in the internal model. PassNoneto remove the object’s position.
sourcefn as_any(&self) -> &dyn Any
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.
sourcefn as_any_mut(&mut self) -> &mut dyn Any
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§
impl RailwayObject for Train
Implements the RailwayObject trait for the Train struct.