Skip to main content

Arrangements

Struct Arrangements 

Source
pub struct Arrangements<T>(/* private fields */);
Expand description

Generic collection for ArrangementFiles.

§Serialize/Deserialize

Neither Serialize nor Deserialize are implemented for this type.

§Box (no Copy)

The inner array of this type is wrapped in a Box. – we cannot fit all ArrangementFiles on the stack. Unfortunately this means the type does not implement Copy.

§Example: Extending in your own code with custom inner types

use std::path::PathBuf;
use ot_tools_io::types::Arrangements;

use ot_tools_io::Defaults;
use ot_tools_io_derive::{ArrayDefaults, BoxedArrayDefaults};
use std::array::from_fn;

#[derive(Debug, PartialEq, Default, ArrayDefaults, BoxedArrayDefaults)]
pub struct BackupPath(PathBuf);

let mut my_backups = Arrangements::<BackupPath>::default();
let my_new_backup = BackupPath(PathBuf::from("some_path"));
let first = my_backups.first_mut().ok_or(())?;
*first = my_new_backup;

// first one changed
assert_eq!(my_backups[0], BackupPath(PathBuf::from("some_path")));
// rest are default
assert_eq!(my_backups[1], BackupPath::default());

// correct length
assert_eq!(my_backups.len(), 8);

Implementations§

Source§

impl<T> Arrangements<T>

Source

pub fn new(value: [T; 8]) -> Self

Source

pub fn new_boxed(value: Box<[T; 8]>) -> Self

Source§

impl<T> Arrangements<T>

Source

pub fn id_ref(&self, id: &ArrId) -> &T

Returns a reference to an element of the array data

§Panic-free

This method is panic-free as the id type is guaranteed to never exceed the max index of the underlying array.

Source

pub fn id_mut(&mut self, id: &ArrId) -> &mut T

Returns a mutable reference to an element the array data

§Panic-free

This method is panic-free as the id type is guaranteed to never exceed the max index of the underlying array.

Source§

impl<T: Copy> Arrangements<T>

Source

pub fn id(self, id: &ArrId) -> T

Returns an owned element of the array data

§Panic-free

This method is panic-free as the id type is guaranteed to never exceed the max index of the underlying array.

Source§

impl<T> Arrangements<T>

Source

pub fn unbox(self) -> [T; 8]

Returns an owned [T; 16] by “un-boxing” (dereferencing) the data

Source

pub fn unbox_ref(&self) -> &[T; 8]

Returns a referenced [T; 16] by “un-boxing” (dereferencing) the data

Source

pub fn unbox_mut(&mut self) -> &mut [T; 8]

Returns a mutably referenced [T; 16] by “un-boxing” (dereferencing) the data

Source§

impl Arrangements<ArrangementFile>

Concrete implementation for ArrangementFile adds two methods for reading and writing a batch of files.

Source

pub fn from_data_files<P>( dirpath: P, state: &SavedState, ) -> Result<Self, OtToolsIoError>
where PathBuf: From<P>,

Reads a collection of ArrangementFiles from a directory.

Source

pub fn to_data_files<P>( &self, dirpath: P, state: &SavedState, skip_unchanged: bool, ) -> Result<(), OtToolsIoError>
where PathBuf: From<P>,

Writes a collection of ArrangementFiles to a directory.

Will skip writing a particular ArrangementFile if the skip_unchanged argument is true and the current ArrangementFile matches the data in the existing file on the file system.

Trait Implementations§

Source§

impl<T> AsMut<Arrangements<T>> for Arrangements<T>

Source§

fn as_mut(&mut self) -> &mut Arrangements<T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsRef<Arrangements<T>> for Arrangements<T>

Source§

fn as_ref(&self) -> &Arrangements<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for Arrangements<T>

Source§

fn clone(&self) -> Arrangements<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Arrangements<T>

Source§

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

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

impl<T: Defaults<Box<[T; 8]>> + Default> Default for Arrangements<T>

Source§

fn default() -> Self

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

impl<T> Deref for Arrangements<T>

Source§

type Target = [T; 8]

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for Arrangements<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: Eq> Eq for Arrangements<T>

Source§

impl HasHeaderField for Arrangements<ArrangementFile>

Source§

fn check_header(&self) -> Result<bool, OtToolsIoError>

Method to verify if header(s) are valid in some data. See this thread. Read more
Source§

impl<T: Hash> Hash for Arrangements<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Ord> Ord for Arrangements<T>

Source§

fn cmp(&self, other: &Arrangements<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for Arrangements<T>

Source§

fn eq(&self, other: &Arrangements<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: PartialOrd> PartialOrd for Arrangements<T>

Source§

fn partial_cmp(&self, other: &Arrangements<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for Arrangements<T>

Auto Trait Implementations§

§

impl<T> Freeze for Arrangements<T>

§

impl<T> RefUnwindSafe for Arrangements<T>
where T: RefUnwindSafe,

§

impl<T> Send for Arrangements<T>
where T: Send,

§

impl<T> Sync for Arrangements<T>
where T: Sync,

§

impl<T> Unpin for Arrangements<T>

§

impl<T> UnsafeUnpin for Arrangements<T>

§

impl<T> UnwindSafe for Arrangements<T>
where T: UnwindSafe,

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.