Skip to main content

LinkSpace

Struct LinkSpace 

Source
pub struct LinkSpace<P = ()> { /* private fields */ }
Expand description

Generic link-based network space.

Implementations§

Source§

impl<P> LinkSpace<P>

Source

pub fn new() -> Self

Create an empty link space with no nodes or links.

Source

pub fn num_nodes(&self) -> usize

Number of nodes in the network.

Number of links in the network.

Source

pub fn add_node(&mut self) -> NodeId

Add a node and return its index.

Add a directed link from from to to with geometry and per-link properties.

Immutable access to link geometry.

Mutable access to link geometry.

Immutable access to per-link properties.

Mutable access to per-link properties.

Source and destination nodes of a link as (from, to).

Outgoing link IDs from a node.

Incoming link IDs to a node.

Number of agents currently on a link.

Agent IDs currently on a link, ordered by position (upstream first).

Link length in meters.

Set whether a link’s exit is blocked by downstream logic.

Whether a link’s exit is currently blocked.

Source

pub fn agent_position(&self, id: AgentId) -> Option<(LinkId, f64)>

Get an agent’s current link and position.

Place an agent on a link at a specific position.

Source

pub fn remove_agent(&mut self, id: AgentId) -> Result<(), LinkSpaceError>

Remove an agent from the network.

Source

pub fn advance_agent( &mut self, id: AgentId, distance: f64, ) -> Result<f64, LinkSpaceError>

Advance an agent’s position on its current link by distance meters.

Check if an agent has reached the downstream end of its link.

Source

pub fn transfer_agent( &mut self, id: AgentId, to_link: LinkId, ) -> Result<(), LinkSpaceError>

Transfer an agent from the end of its current link to the start of a new link.

Source

pub fn total_agents(&self) -> usize

Total number of agents in the network.

Source

pub fn all_agent_ids(&self) -> Vec<AgentId>

All agent IDs in the network.

Trait Implementations§

Source§

impl<P: Clone> Clone for LinkSpace<P>

Source§

fn clone(&self) -> LinkSpace<P>

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<P: Debug> Debug for LinkSpace<P>

Source§

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

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

impl<P> Default for LinkSpace<P>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<P: Send + Sync> Space for LinkSpace<P>

Auto Trait Implementations§

§

impl<P> Freeze for LinkSpace<P>

§

impl<P> RefUnwindSafe for LinkSpace<P>
where P: RefUnwindSafe,

§

impl<P> Send for LinkSpace<P>
where P: Send,

§

impl<P> Sync for LinkSpace<P>
where P: Sync,

§

impl<P> Unpin for LinkSpace<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for LinkSpace<P>

§

impl<P> UnwindSafe for LinkSpace<P>
where P: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Message for T
where T: Clone + Send + Sync + 'static,