Skip to main content

ExportSettings

Struct ExportSettings 

Source
pub struct ExportSettings<'a> { /* private fields */ }
Expand description

Settings for the DDDMP export

Implementations§

Source§

impl<'a> ExportSettings<'a>

Source

pub fn version(self, version: DDDMPVersion) -> Self

Set the DDDMP format version for the export. Defaults to 2.0.

Source

pub fn get_version(&self) -> DDDMPVersion

Get the currently selected version

Source

pub fn binary_supported<M: Manager>(manager: &M) -> bool

Check if binary mode is supported for the decision diagram kind given by F

Source

pub fn ascii(self) -> Self

Enforce ASCII mode. Nodes will be written in a human-readable way.

By default, binary mode is used if supported. supported.

Source

pub fn binary(self) -> Self

Write nodes in the more compact binary mode if supported. This is the default.

Source

pub fn is_ascii(&self) -> bool

Get whether ASCII mode is enforced or binary mode will be used if supported.

Source

pub fn diagram_name(self, name: &'a str) -> Self

Set the decision diagrams’s name

This corresponds to the .dd field in DDDMP. name should not contain any ASCII control characters (e.g., line breaks). Control characters will be replaced by spaces and in strict mode, an error will be generated during the export.

Source

pub fn get_diagram_name(&self) -> &'a str

Source

pub fn strict(self, strict: bool) -> Self

Enable or disable strict mode

The DDDMP format imposes some restrictions on diagram, variable, and function names:

  • None of them may contain ASCII control characters (e.g., line breaks).
  • Variable and function names must not contain spaces either.
  • Variable and function names must not be empty. (However, it is possible to not export any variable or function names at all.)

In the diagram name, control characters will be replaced by spaces. In variable and function names, an underscore (_) is used as the replacement character. When using Self::export_with_names(), empty function names are replaced by _f{i}, where {i} stands for the position in the iterator. Empty variable names are replaced by _x{i}. To retain uniqueness, as many underscores are added to the prefix as there are in the longest prefix over all present variable names.

However, since such relabelling may lead to unexpected results, there is a strict mode. In strict mode, no variable names will be exported unless all variables are named. Additionally, an error will be generated upon any replacement. The error will not be propagated immediately but only after the file was written. This should simplify inspecting the error and also serve as a checkpoint for very long-running computations.

By default, strict mode is enabled.

Source

pub fn is_strict(&self) -> bool

Getter for Self::strict()

Source

pub fn export<'id, FR: Deref>( &self, file: impl Write, manager: &<FR::Target as Function>::Manager<'id>, functions: impl IntoIterator<Item = FR>, ) -> Result<()>

Export the decision diagram to file

functions is an iterator over (references to) Functions. All nodes reachable from the root nodes of these functions will be included in the dump.

Use Self::export_with_names() if you wish to assign names to the functions.

Returns an error in case of an I/O failure or if strict mode is enabled and the diagram name or a variable name does not meet the requirements. In case one of the strict mode requirements is violated, the implementation attempts to complete the export before reporting the error. This is to help inspecting the error and also to save a checkpoint for very long-running computations.

§Example
let file = std::fs::File::create("foo.dddmp")?;
f.with_manager_shared(|manager, _| {
    ExportSettings::default()
        .diagram_name("foo")
        .export(file, manager, [f, g, h])
})?;
Source

pub fn export_with_names<'id, FR: Deref, D: Display>( &self, file: impl Write, manager: &<FR::Target as Function>::Manager<'id>, functions: impl IntoIterator<Item = (FR, D)>, ) -> Result<()>

Create a new export with function names

functions is an iterator over pairs of (references to) Functions and names. All nodes reachable from the root nodes of these functions will be included in the dump.

All functions names should be non-empty strings without spaces or ASCII control characters (e.g., newlines) due to requirements of the DDDMP format. Each space or ASCII control character will be replaced by an underscore (_). Empty names will be replaced by _f{i}. If strict mode is enabled, a replacement will be reported as an error during export.

Returns an error in case of an I/O failure or if strict mode is enabled and the diagram name, a function name or a variable name does not meet the requirements. In case one of the strict mode requirements is violated, the implementation attempts to complete the export before reporting the error. This is to help inspecting the error and also to save a checkpoint for very long-running computations.

§Example
let file = std::fs::File::create("foo.dddmp")?;
f.with_manager_shared(|manager, _| {
    ExportSettings::default()
        .diagram_name("foo")
        .export_with_names(file, manager, [(f, "f"), (g, "g"), (h, "h")])
})?;

Trait Implementations§

Source§

impl<'a> Clone for ExportSettings<'a>

Source§

fn clone(&self) -> ExportSettings<'a>

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<'a> Debug for ExportSettings<'a>

Source§

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

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

impl Default for ExportSettings<'_>

Source§

fn default() -> Self

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

impl<'a> Copy for ExportSettings<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ExportSettings<'a>

§

impl<'a> RefUnwindSafe for ExportSettings<'a>

§

impl<'a> Send for ExportSettings<'a>

§

impl<'a> Sync for ExportSettings<'a>

§

impl<'a> Unpin for ExportSettings<'a>

§

impl<'a> UnsafeUnpin for ExportSettings<'a>

§

impl<'a> UnwindSafe for ExportSettings<'a>

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.