Skip to main content

AssetPool

Struct AssetPool 

Source
pub struct AssetPool {
    assets: Vec<AssetRef>,
    next_id: u32,
    next_group_id: u32,
}
Expand description

The active pool of super::Assets

Fields§

§assets: Vec<AssetRef>

The pool of active assets, sorted by ID

§next_id: u32

Next available asset ID number

§next_group_id: u32

Next available group ID number

Implementations§

Source§

impl AssetPool

Source

pub fn new() -> Self

Create a new empty 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, user_assets: &mut Vec<AssetRef>, ) -> &[AssetRef]

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

Returns the newly commissioned assets (children, for divisible assets).

Source

fn commission(&mut self, asset: AssetRef, reason: &str)

Commission the specified asset or, if divisible, its children

Source

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

Decommission old assets for the specified milestone year

Source

pub fn decommission_mothballed(&mut self, year: u32, mothball_years: u32)

Decommission mothballed assets if mothballed long enough

Source

pub fn mothball_unretained<I>(&mut self, assets: I, year: u32)
where I: IntoIterator<Item = AssetRef>,

Mothball the specified assets if they are no longer in the active pool and put them back again.

§Arguments
  • assets - Assets to possibly mothball
  • year - Mothball year
§Panics

Panics if any of the provided assets was never commissioned.

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 take(&mut self) -> Vec<AssetRef>

Return current active pool and clear

Source

pub fn extend<I>(&mut self, assets: I) -> &[AssetRef]
where I: IntoIterator<Item = AssetRef>,

Extend the active pool with Commissioned or Selected assets.

Returns the newly commissioned assets (those that were in Selected state on entry).

Trait Implementations§

Source§

impl Default for AssetPool

Source§

fn default() -> AssetPool

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

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.