Struct survex_rs::data::SurveyData

source ·
pub struct SurveyData {
    pub stations: Vec<Rc<RefCell<Station>>>,
    pub graph: UnGraph<String, f64>,
}
Expand description

Handles the creation and management of stations, as well as holding the graph of stations.

Fields§

§stations: Vec<Rc<RefCell<Station>>>§graph: UnGraph<String, f64>

Implementations§

source§

impl SurveyData

source

pub fn new() -> Self

Create an empty SurveyData instance with no stations or connections. This method should not be used directly. Instead, create a SurveyData instance from a Survex file using the load_from_path helper function.

source

pub fn get_by_label(&self, label: &str) -> Option<Rc<RefCell<Station>>>

Retrieve a reference to a Station by its label.

source

pub fn get_by_coords(&self, coords: &Point) -> Option<Rc<RefCell<Station>>>

Retrieve a reference to a Station by its coordinates. If multiple stations exist at the given coordinates, the first station found is returned.

source

pub fn add_or_update( &mut self, coords: Point, label: &str ) -> (Rc<RefCell<Station>>, NodeIndex)

This helper method is used to add or update a Station to both the stations vector and the graph.

If a Station with the given label already exists, the existing station is updated with the new coordinates. Otherwise, a new Station is created and added to the stations vector and the graph. In either case, a reference to the station is returned in a tuple along with the index of the station in the graph.

Trait Implementations§

source§

impl Default for SurveyData

source§

fn default() -> Self

Returns an empty SurveyData instance with no stations.

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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

§

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.