pub struct ExportSettings<'a> { /* private fields */ }Expand description
Settings for the DDDMP export
Implementations§
Source§impl<'a> ExportSettings<'a>
impl<'a> ExportSettings<'a>
Sourcepub fn version(self, version: DDDMPVersion) -> Self
pub fn version(self, version: DDDMPVersion) -> Self
Set the DDDMP format version for the export. Defaults to 2.0.
Sourcepub fn get_version(&self) -> DDDMPVersion
pub fn get_version(&self) -> DDDMPVersion
Get the currently selected version
Sourcepub fn binary_supported<M: Manager>(manager: &M) -> bool
pub fn binary_supported<M: Manager>(manager: &M) -> bool
Check if binary mode is supported for the decision diagram kind given by
F
Sourcepub fn ascii(self) -> Self
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.
Sourcepub fn binary(self) -> Self
pub fn binary(self) -> Self
Write nodes in the more compact binary mode if supported. This is the default.
Sourcepub fn is_ascii(&self) -> bool
pub fn is_ascii(&self) -> bool
Get whether ASCII mode is enforced or binary mode will be used if supported.
Sourcepub fn diagram_name(self, name: &'a str) -> Self
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.
Sourcepub fn get_diagram_name(&self) -> &'a str
pub fn get_diagram_name(&self) -> &'a str
Getter for Self::diagram_name()
Sourcepub fn strict(self, strict: bool) -> Self
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.
Sourcepub fn is_strict(&self) -> bool
pub fn is_strict(&self) -> bool
Getter for Self::strict()
Sourcepub fn export<'id, FR: Deref>(
&self,
file: impl Write,
manager: &<FR::Target as Function>::Manager<'id>,
functions: impl IntoIterator<Item = FR>,
) -> Result<()>where
FR::Target: Function,
INodeOfFunc<'id, FR::Target>: HasLevel,
TermOfFunc<'id, FR::Target>: AsciiDisplay,
pub fn export<'id, FR: Deref>(
&self,
file: impl Write,
manager: &<FR::Target as Function>::Manager<'id>,
functions: impl IntoIterator<Item = FR>,
) -> Result<()>where
FR::Target: Function,
INodeOfFunc<'id, FR::Target>: HasLevel,
TermOfFunc<'id, FR::Target>: AsciiDisplay,
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])
})?;Sourcepub 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<()>where
FR::Target: Function,
INodeOfFunc<'id, FR::Target>: HasLevel,
TermOfFunc<'id, FR::Target>: AsciiDisplay,
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<()>where
FR::Target: Function,
INodeOfFunc<'id, FR::Target>: HasLevel,
TermOfFunc<'id, FR::Target>: AsciiDisplay,
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>
impl<'a> Clone for ExportSettings<'a>
Source§fn clone(&self) -> ExportSettings<'a>
fn clone(&self) -> ExportSettings<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more