Struct AssetPool

Source
pub struct AssetPool {
    active: Vec<AssetRef>,
    future: Vec<Asset>,
    next_id: u32,
}
Expand description

A pool of Assets

Fields§

§active: Vec<AssetRef>

The pool of active assets

§future: Vec<Asset>

Assets that have not yet been commissioned, sorted by commission year

§next_id: u32

Next available asset ID number

Implementations§

Source§

impl AssetPool

Source

pub fn new(assets: Vec<Asset>) -> Self

Create a new AssetPool

Source

pub fn as_slice(&self) -> &[AssetRef]

Get the active pool as a slice of AssetRefs

Source

pub fn commission_new(&mut self, year: u32)

Commission new assets for the specified milestone year from the input data

Source

pub fn decommission_old(&mut self, year: u32)

Decommission old assets for the specified milestone year

Source

pub fn get(&self, id: AssetID) -> Option<&AssetRef>

Get an asset with the specified ID.

§Returns

An AssetRef if found, else None. The asset may not be found if it has already been decommissioned.

Source

pub fn iter(&self) -> Iter<'_, AssetRef>

Iterate over active assets

Source

pub fn replace_active_pool<I>(&mut self, assets: I)
where I: IntoIterator<Item = Rc<Asset>>,

Replace the active pool with new and/or already commissioned assets

Auto Trait Implementations§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.