Struct sim::transit::TransitSimState
source · [−]pub(crate) struct TransitSimState {
buses: BTreeMap<CarID, Bus>,
routes: BTreeMap<TransitRouteID, Route>,
peds_waiting: BTreeMap<TransitStopID, Vec<(PedestrianID, TransitRouteID, Option<TransitStopID>, Time)>>,
events: Vec<Event>,
}
Expand description
Manages public transit vehicles (buses and trains) that follow a route. The transit model is currently kind of broken, so not describing the state machine yet.
Fields
buses: BTreeMap<CarID, Bus>
routes: BTreeMap<TransitRouteID, Route>
peds_waiting: BTreeMap<TransitStopID, Vec<(PedestrianID, TransitRouteID, Option<TransitStopID>, Time)>>
waiting at => (ped, route, bound for, started waiting)
events: Vec<Event>
Implementations
sourceimpl TransitSimState
impl TransitSimState
pub fn new(map: &Map) -> TransitSimState
sourcepub fn create_empty_route(
&mut self,
bus_route: &TransitRoute,
map: &Map
) -> Path
pub fn create_empty_route(
&mut self,
bus_route: &TransitRoute,
map: &Map
) -> Path
Returns the path for the first leg.
pub fn bus_created(&mut self, bus: CarID, r: TransitRouteID)
sourcepub fn bus_arrived_at_stop(
&mut self,
now: Time,
id: CarID,
trips: &mut TripManager,
walking: &mut WalkingSimState,
ctx: &mut Ctx<'_>
) -> bool
pub fn bus_arrived_at_stop(
&mut self,
now: Time,
id: CarID,
trips: &mut TripManager,
walking: &mut WalkingSimState,
ctx: &mut Ctx<'_>
) -> bool
If true, the bus is idling. If false, the bus actually arrived at a border and should now vanish.
TODO Misnomer – callback from Router::follow_bus_route
pub fn bus_departed_from_stop(&mut self, id: CarID, _: &Map) -> Router
sourcepub fn ped_waiting_for_bus(
&mut self,
now: Time,
ped: PedestrianID,
trip: TripID,
person: PersonID,
stop1: TransitStopID,
route_id: TransitRouteID,
maybe_stop2: Option<TransitStopID>,
_: &Map
) -> Option<CarID>
pub fn ped_waiting_for_bus(
&mut self,
now: Time,
ped: PedestrianID,
trip: TripID,
person: PersonID,
stop1: TransitStopID,
route_id: TransitRouteID,
maybe_stop2: Option<TransitStopID>,
_: &Map
) -> Option<CarID>
Returns the bus if the pedestrian boarded immediately.
pub fn collect_events(&mut self) -> Vec<Event>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_passengers(
&self,
bus: CarID
) -> &Vec<(PersonID, Option<TransitStopID>)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn bus_route(&self, bus: CarID) -> TransitRouteID
sourcepub fn buses_for_route(
&self,
route: TransitRouteID
) -> Vec<(CarID, Option<usize>)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn buses_for_route(
&self,
route: TransitRouteID
) -> Vec<(CarID, Option<usize>)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
also stop idx that the bus is coming from
pub fn get_people_waiting_at_stop(
&self,
at: TransitStopID
) -> &Vec<(PedestrianID, TransitRouteID, Option<TransitStopID>, Time)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_unzoomed_transit_riders(
&self,
now: Time,
driving: &DrivingSimState,
map: &Map
) -> Vec<UnzoomedAgent>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Trait Implementations
sourceimpl Clone for TransitSimState
impl Clone for TransitSimState
sourcefn clone(&self) -> TransitSimState
fn clone(&self) -> TransitSimState
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'de> Deserialize<'de> for TransitSimState
impl<'de> Deserialize<'de> for TransitSimState
sourcefn 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
sourceimpl Serialize for TransitSimState
impl Serialize for TransitSimState
Auto Trait Implementations
impl RefUnwindSafe for TransitSimState
impl Send for TransitSimState
impl Sync for TransitSimState
impl Unpin for TransitSimState
impl UnwindSafe for TransitSimState
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more