pub struct Formations {
    pub inner: Vec<Formation>,
}
Expand description

This struct represents a Local Formation. I.e. one the user can interact with on the CLI and can be (de)serialized locally.

A somewhat counter-intuitive thing about “Formations” and their models is the there is no “Formation Model” only a “Formation Model” This is because a “Formation” so to speak is really just a named collection of configurations and info about their traffic weights/activation statuses.

Fields§

§inner: Vec<Formation>

A list of “Formation“s

Implementations§

source§

impl Formations

source

pub fn extend(&mut self, rhs: &Formations)

Extend and de-duplicate from another set of Formations

source

pub fn oids_from_indices(&self, indices: &[usize]) -> Vec<FormationId>

source

pub fn formation_indices_of_matches( &self, name_id: &FormationNameId ) -> Vec<usize>

Returns all indices of an exact name or partial ID match

source

pub fn formation_indices_of_partial_matches( &self, name_id: &FormationNameId ) -> Vec<usize>

Returns all indices of a partial name or ID match

The odd thing about how this works is due to FormationNameId. A partial OID is not a valid FormationId, thus it gets interpreted as a name. So in this partial search we only use the Name variant of the FormationNameId

However, if a full OID is passed, we check it like normal

source

pub fn remove_formation_indices(&mut self, indices: &[usize]) -> Vec<Formation>

Removes all indices

source

pub fn get_by_name_id(&self, name_id: &FormationNameId) -> Option<&Formation>

source

pub fn has_flight(&self, flight: &str) -> bool

source

pub fn create_or_update(&mut self, formation: FormationModel)

Either updates a matching local Formations, or creates a new one

source

pub fn update(&mut self, model: &FormationModel)

We got a response from the API that has filled in all the OIDs for a Formation/Flights and URL so we update those here

source

pub fn contains(&self, name_id: &FormationNameId) -> bool

Returns true if there is a Formation with the given name or OID

source

pub fn remove(&mut self, name_id: &FormationNameId) -> Option<Formation>

Removes an exact name match, returning the removed Formation or None if nothing matched.

DANGER: this will invalidate any previously held indices after the removed item

source

pub fn statuses(&self) -> Vec<FormationStatus>

source

pub fn index_of(&self, name_id: &FormationNameId) -> Option<usize>

source

pub fn add(&mut self, formation: Formation)

source

pub fn iter(&self) -> impl Iterator<Item = &Formation>

source

pub fn get(&self, idx: usize) -> Option<&Formation>

source

pub fn get_mut(&mut self, idx: usize) -> Option<&mut Formation>

Trait Implementations§

source§

impl Clone for Formations

source§

fn clone(&self) -> Formations

Returns a copy 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 Formations

source§

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

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

impl Default for Formations

source§

fn default() -> Formations

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

impl<'de> Deserialize<'de> for Formations

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Output for Formations

source§

fn print_json(&self, _ctx: &Ctx) -> Result<()>

source§

fn print_table(&self, _ctx: &Ctx) -> Result<()>

source§

impl Serialize for Formations

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,