Train

Struct Train 

Source
pub struct Train { /* private fields */ }
Expand description

This class implements a train.

A train travels down the track passing or stoping at stations along the way.

Implementations§

Source§

impl Train

Source

pub fn new( name: String, number: String, speed: u32, classnumber: u32, departure: u32, startsmile: f64, start: usize, end: usize, ) -> Self

Create and initialize a train object.

  • §Parameters:
    • name The name of the train.
    • number The number (or symbol) of the train.
    • speed The maximum (scale) speed of the train.
    • classnumber The class of the train.
    • departure The train’s departure time.
        • startsmile The starting Scale Mile
    • start The originating station index.
    • end The terminating station index.
Source

pub fn Name(&self) -> String

Return the name of the train.

Source

pub fn Number(&self) -> String

Return the number (or symbol) of the train.

Source

pub fn Departure(&self) -> u32

Return the departure time.

Source

pub fn SetDeparture(&mut self, depart: u32)

Update departure time.

§Parameters:
  • depart The new departure time.
Source

pub fn DepartureCompare(&self, other: &Self) -> Ordering

Source

pub fn Speed(&self) -> u32

Return the train’s speed.

Source

pub fn ClassNumber(&self) -> u32

Return the class number.

Source

pub fn NumberOfNotes(&self) -> usize

Number of notes.

Source

pub fn Note(&self, i: usize) -> Option<&usize>

Return the ith note.

Returns -1 if the index is out of range.

§Parameters:
  • i The index of the note.
Source

pub fn AddNoteToTrain(&mut self, note: usize)

Add a note.

§Parameters:
  • note The note number to add.
Source

pub fn RemoveNoteFromTrain(&mut self, note: usize)

Remove a note.

§Parameters:
  • note The note number to remove.
Source

pub fn NoteIter(&self) -> Iter<'_, usize>

Source

pub fn NoteIter_mut(&mut self) -> IterMut<'_, usize>

Source

pub fn UpdateStopLayover(&mut self, istop: usize, layover: f64)

Update stop layover.

§Parameters:
  • istop The stop number to update.
  • layover The new layover time.
Source

pub fn UpdateStopCab(&mut self, istop: usize, cab: Option<&Cab>)

Update the cab.

§Parameters:
  • istop The stop number to update.
  • cab The new cab.
Source

pub fn AddNoteToStop(&mut self, istop: usize, note: usize)

Add a note to a stop.

§Parameters:
  • istop The stop number to update.
  • note The note to add.
Source

pub fn RemoveNoteFromStop(&mut self, istop: usize, note: usize)

Remove a note from a stop.

§Parameters:
  • istop The stop number to update.
  • note The note to remove.
Source

pub fn SetOriginStorageTrack(&mut self, trackname: String)

Set the origin storage track.

§Parameters:
  • trackname The originating storage track name.
Source

pub fn SetDestinationStorageTrack(&mut self, trackname: String)

Set the destination storage track.

§Parameters:
  • trackname The terminating storage track name.
Source

pub fn SetTransitStorageTrack(&mut self, istop: usize, trackname: String)

Set an intermediate storage track.

§Parameters:
  • istop The stop index.
  • trackname The intermediate storage track name.
Source

pub fn NumberOfStops(&self) -> usize

Return the number of stops.

Source

pub fn StopI(&self, i: usize) -> Option<&Stop>

Return the ith stop object. Returns NULL if the index is out of range.

§Parameters:
  • i The index of the stop.
Source

pub fn StopIter(&self) -> Iter<'_, Stop>

Source

pub fn StopIter_mut(&mut self) -> IterMut<'_, Stop>

Source

pub fn StartSMile(&self) -> f64

Return the start Scale Mile.

Source

pub fn ParseTrain(string: &str) -> Result<(Self, usize), TrainParseError>

Source

pub fn Read( inp: &mut BufReader<File>, cabs: &CabNameMap, ) -> Result<Option<Self>>

Source

pub fn Write(&self, f: &mut BufWriter<File>) -> Result<()>

Trait Implementations§

Source§

impl Clone for Train

Source§

fn clone(&self) -> Train

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Train

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Train

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Train

Source§

fn from_str(string: &str) -> Result<Self, Self::Err>

Convert from &str to Self

Source§

type Err = TrainParseError

The associated error which can be returned from parsing.
Source§

impl PartialEq for Train

Source§

fn eq(&self, other: &Train) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Train

Auto Trait Implementations§

§

impl Freeze for Train

§

impl RefUnwindSafe for Train

§

impl Send for Train

§

impl Sync for Train

§

impl Unpin for Train

§

impl UnwindSafe for Train

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.