Struct seaplane_cli::ops::formation::Formations
source · 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
impl Formations
sourcepub fn extend(&mut self, rhs: &Formations)
pub fn extend(&mut self, rhs: &Formations)
Extend and de-duplicate from another set of Formations
pub fn oids_from_indices(&self, indices: &[usize]) -> Vec<FormationId>
sourcepub fn formation_indices_of_matches(
&self,
name_id: &FormationNameId
) -> Vec<usize>
pub fn formation_indices_of_matches( &self, name_id: &FormationNameId ) -> Vec<usize>
Returns all indices of an exact name or partial ID match
sourcepub fn formation_indices_of_partial_matches(
&self,
name_id: &FormationNameId
) -> Vec<usize>
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
sourcepub fn remove_formation_indices(&mut self, indices: &[usize]) -> Vec<Formation>
pub fn remove_formation_indices(&mut self, indices: &[usize]) -> Vec<Formation>
Removes all indices
pub fn get_by_name_id(&self, name_id: &FormationNameId) -> Option<&Formation>
pub fn has_flight(&self, flight: &str) -> bool
sourcepub fn create_or_update(&mut self, formation: FormationModel)
pub fn create_or_update(&mut self, formation: FormationModel)
Either updates a matching local Formations, or creates a new one
sourcepub fn update(&mut self, model: &FormationModel)
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
sourcepub fn contains(&self, name_id: &FormationNameId) -> bool
pub fn contains(&self, name_id: &FormationNameId) -> bool
Returns true if there is a Formation with the given name or OID
sourcepub fn remove(&mut self, name_id: &FormationNameId) -> Option<Formation>
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
pub fn statuses(&self) -> Vec<FormationStatus>
pub fn index_of(&self, name_id: &FormationNameId) -> Option<usize>
pub fn add(&mut self, formation: Formation)
pub fn iter(&self) -> impl Iterator<Item = &Formation>
pub fn get(&self, idx: usize) -> Option<&Formation>
pub fn get_mut(&mut self, idx: usize) -> Option<&mut Formation>
Trait Implementations§
source§impl Clone for Formations
impl Clone for Formations
source§fn clone(&self) -> Formations
fn clone(&self) -> Formations
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more