Struct CellMapFile

Source
pub struct CellMapFile<L, T>
where L: Layer,
{ pub num_layers: usize, pub layers: Vec<L>, pub cell_bounds: Bounds, pub cell_size: Vector2<f64>, pub cell_boundary_precision: f64, pub from_parent_angle_rad: f64, pub from_parent_translation: Vector2<f64>, pub from_parent_matrix: Affine2<f64>, pub data: Vec<Array2<T>>, }
Expand description

Represents a file that can be serialised and deserialised using serde.

Fields§

§num_layers: usize

Number of layers stored in the map

§layers: Vec<L>

The order of layers in the map.

The index of a layer name in this vector matches the index of that layer in the data member.

§cell_bounds: Bounds

The bounds of the map

§cell_size: Vector2<f64>

The size of each cell in the map, in parent-frame units.

§cell_boundary_precision: f64

The precision used when calculating cell boundaries, relative to cell_size.

§from_parent_angle_rad: f64

The angle which rotates the parent frame into the map frame, in radians.

§from_parent_translation: Vector2<f64>

The translation that goes from the parent frame to the map frame, in parent frame units.

§from_parent_matrix: Affine2<f64>

The affine transformation matrix that converts from points in the parent frame to the map frame.

§data: Vec<Array2<T>>

Stores each layer of the map as an ndarray::Array2<T>.

Implementations§

Source§

impl<L, T> CellMapFile<L, T>
where L: Layer,

Source

pub fn into_cell_map(self) -> Result<CellMap<L, T>, Error>

Converts this file into a CellMap.

Source§

impl<L, T> CellMapFile<L, T>
where L: Layer + Serialize, T: Serialize,

Source

pub fn write_json<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Writes the CellMapFile to the given path, overwriting any existing file. The format of the written file is JSON.

Source§

impl<L, T> CellMapFile<L, T>

Source

pub fn from_json<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Loads a CellMapFile from the given path, which points to a JSON file.

Trait Implementations§

Source§

impl<L, T: Clone> Clone for CellMapFile<L, T>
where L: Layer + Clone,

Source§

fn clone(&self) -> CellMapFile<L, T>

Returns a duplicate 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<L, T: Debug> Debug for CellMapFile<L, T>
where L: Layer + Debug,

Source§

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

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

impl<'de, L, T> Deserialize<'de> for CellMapFile<L, T>
where L: Layer + Deserialize<'de>, T: Deserialize<'de>,

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<L, T> From<CellMap<L, T>> for CellMapFile<L, T>
where L: Layer + Serialize, T: Clone + Serialize,

Source§

fn from(map: CellMap<L, T>) -> Self

Converts to this type from the input type.
Source§

impl<L, T> Serialize for CellMapFile<L, T>
where L: Layer + Serialize, T: Serialize,

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
Source§

impl<L, T> TryFrom<CellMapFile<L, T>> for CellMap<L, T>
where L: Layer,

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: CellMapFile<L, T>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<L, T> Freeze for CellMapFile<L, T>

§

impl<L, T> RefUnwindSafe for CellMapFile<L, T>

§

impl<L, T> Send for CellMapFile<L, T>
where L: Send, T: Send,

§

impl<L, T> Sync for CellMapFile<L, T>
where L: Sync, T: Sync,

§

impl<L, T> Unpin for CellMapFile<L, T>
where L: Unpin,

§

impl<L, T> UnwindSafe for CellMapFile<L, T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,