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>
impl<T> Arrangements<T>
Source§impl<T> Arrangements<T>
impl<T> Arrangements<T>
Source§impl<T: Copy> Arrangements<T>
impl<T: Copy> Arrangements<T>
Source§impl<T> Arrangements<T>
impl<T> Arrangements<T>
Source§impl Arrangements<ArrangementFile>
Concrete implementation for ArrangementFile adds two methods for reading and writing a
batch of files.
impl Arrangements<ArrangementFile>
Concrete implementation for ArrangementFile adds two methods for reading and writing a
batch of files.
Sourcepub fn from_data_files<P>(
dirpath: P,
state: &SavedState,
) -> Result<Self, OtToolsIoError>
pub fn from_data_files<P>( dirpath: P, state: &SavedState, ) -> Result<Self, OtToolsIoError>
Reads a collection of ArrangementFiles from a directory.
Sourcepub fn to_data_files<P>(
&self,
dirpath: P,
state: &SavedState,
skip_unchanged: bool,
) -> Result<(), OtToolsIoError>
pub fn to_data_files<P>( &self, dirpath: P, state: &SavedState, skip_unchanged: bool, ) -> Result<(), OtToolsIoError>
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>
impl<T> AsMut<Arrangements<T>> for Arrangements<T>
Source§fn as_mut(&mut self) -> &mut Arrangements<T>
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>
impl<T> AsRef<Arrangements<T>> for Arrangements<T>
Source§fn as_ref(&self) -> &Arrangements<T>
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>
impl<T: Clone> Clone for Arrangements<T>
Source§fn clone(&self) -> Arrangements<T>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for Arrangements<T>
impl<T: Debug> Debug for Arrangements<T>
Source§impl<T> Deref for Arrangements<T>
impl<T> Deref for Arrangements<T>
Source§impl<T> DerefMut for Arrangements<T>
impl<T> DerefMut for Arrangements<T>
impl<T: Eq> Eq for Arrangements<T>
Source§impl HasHeaderField for Arrangements<ArrangementFile>
impl HasHeaderField for Arrangements<ArrangementFile>
Source§fn check_header(&self) -> Result<bool, OtToolsIoError>
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>
impl<T: Hash> Hash for Arrangements<T>
Source§impl<T: Ord> Ord for Arrangements<T>
impl<T: Ord> Ord for Arrangements<T>
Source§fn cmp(&self, other: &Arrangements<T>) -> Ordering
fn cmp(&self, other: &Arrangements<T>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq> PartialEq for Arrangements<T>
impl<T: PartialEq> PartialEq for Arrangements<T>
Source§impl<T: PartialOrd> PartialOrd for Arrangements<T>
impl<T: PartialOrd> PartialOrd for Arrangements<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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