Struct DataFile

Source
pub struct DataFile<Int> { /* private fields */ }
Expand description

The top-level structure which represents a data file.

A data file is a key-value store, where the key is a MiniZinc identifier, and the value is one of:

  • int
  • bool
  • array of one of the above

Conceptually, the integers in the MiniZinc specification are unbounded, which means the scalar signed integers not model the DZN integers well. However, from a practical standpoint, many uses of DZN files do only deal with i32 or others. Therefore, DataFile is generic over the integer type to allow the user to decide how big the integers can be.

Implementations§

Source§

impl<Int: Integer> DataFile<Int>

Source

pub fn get<T>(&self, key: &str) -> Option<&T>
where Value<Int>: GetValue<T>,

Get a value from the data file with the given key.

When attempting to get a specific type, this method does not discriminate to the key not existing at all, or whether the value is a different type. In either situation, None is returned.

Source

pub fn array_1d<T>( &self, key: &str, length: usize, ) -> Option<&ShapedArray<T, 1>>
where ValueArray<Int, 1>: GetValue<ShapedArray<T, 1>>,

Get a 1-dimensional array from the data file with the given key and length.

Source

pub fn array_2d<T>( &self, key: &str, shape: [usize; 2], ) -> Option<&ShapedArray<T, 2>>
where ValueArray<Int, 2>: GetValue<ShapedArray<T, 2>>,

Get a 2-dimensional array from the data file with the given key.

The array shape should match shape.

Trait Implementations§

Source§

impl<Int: Clone> Clone for DataFile<Int>

Source§

fn clone(&self) -> DataFile<Int>

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<Int: Debug> Debug for DataFile<Int>

Source§

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

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

impl<Int: Default> Default for DataFile<Int>

Source§

fn default() -> DataFile<Int>

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

Auto Trait Implementations§

§

impl<Int> Freeze for DataFile<Int>

§

impl<Int> RefUnwindSafe for DataFile<Int>
where Int: RefUnwindSafe,

§

impl<Int> Send for DataFile<Int>
where Int: Send,

§

impl<Int> Sync for DataFile<Int>
where Int: Sync,

§

impl<Int> Unpin for DataFile<Int>
where Int: Unpin,

§

impl<Int> UnwindSafe for DataFile<Int>
where Int: 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<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> 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.