pub struct Formations {
pub formations: Vec<Formation>,
pub configurations: Vec<FormationConfiguration>,
/* private fields */
}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 Configuration 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§
§formations: Vec<Formation>A list of “Formation“s
configurations: Vec<FormationConfiguration>A list of “Formation Configuration“s
We keep these separate from the Formation themselves because multiple formations can reference the same configuration.
Implementations§
Source§impl Formations
impl Formations
pub fn get_configuration_by_uuid( &self, uuid: Uuid, ) -> Option<&FormationConfiguration>
pub fn remote_names(&self) -> Vec<&str>
pub fn has_flight(&self, flight: &str) -> bool
pub fn formations(&self) -> impl Iterator<Item = &Formation>
pub fn configurations(&self) -> impl Iterator<Item = &FormationConfiguration>
pub fn get_configuration(&self, id: &Id) -> Option<&FormationConfiguration>
Sourcepub fn remove_configuration(
&mut self,
id: &Id,
) -> Option<FormationConfiguration>
pub fn remove_configuration( &mut self, id: &Id, ) -> Option<FormationConfiguration>
Returns the removed FormationConfiguration by ID or None if there was no match
DANGER: this will invalidate any previously held indices after the removed item
pub fn get_formation(&self, idx: usize) -> Option<&Formation>
pub fn get_formation_mut(&mut self, idx: usize) -> Option<&mut Formation>
Sourcepub fn update_or_create_configuration(
&mut self,
cfg: FormationConfiguration,
) -> Option<Id>
pub fn update_or_create_configuration( &mut self, cfg: FormationConfiguration, ) -> Option<Id>
Either updates a matching local Formation Configurations, or creates a new one. Returns the existing ID of the config that was updated if any
Sourcepub fn update_or_create_formation(&mut self, formation: Formation) -> Option<Id>
pub fn update_or_create_formation(&mut self, formation: Formation) -> Option<Id>
Either updates a matching local Formations by replacing the local IDs, or creates a new one. Returns NEW Formations IDs
pub fn add_uuid(&mut self, id: &Id, uuid: Uuid)
pub fn add_in_air_by_name(&mut self, name: &str, id: Id)
pub fn add_grounded_by_name(&mut self, name: &str, id: Id)
Sourcepub fn contains_name(&self, name: &str) -> bool
pub fn contains_name(&self, name: &str) -> bool
Returns true if there is a Formation with the given name
Sourcepub fn remove_name(&mut self, name: &str) -> Option<Formation>
pub fn remove_name(&mut self, name: &str) -> 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
Sourcepub fn formation_index_of_name(&self, name: &str) -> Option<usize>
pub fn formation_index_of_name(&self, name: &str) -> Option<usize>
Returns the index of an exact name match
pub fn configuration_index_of_id(&self, id: &Id) -> Option<usize>
Sourcepub fn formation_indices_of_matches(&self, name: &str) -> Vec<usize>
pub fn formation_indices_of_matches(&self, name: &str) -> Vec<usize>
Returns all indices of an exact name or partial ID match
Sourcepub fn formation_indices_of_left_matches(&self, name: &str) -> Vec<usize>
pub fn formation_indices_of_left_matches(&self, name: &str) -> Vec<usize>
Returns all indices of a partial name or ID match
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
Sourcepub fn remove_flight(&mut self, flight: &str)
pub fn remove_flight(&mut self, flight: &str)
Removes the given flight from all formations that reference it
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