#[non_exhaustive]pub struct WriteOptions {
pub compression: Option<u8>,
pub version: Option<String>,
pub validate: bool,
}Expand description
Tuning knobs for write_with.
Construct from Default and adjust:
use nir_rs::io::WriteOptions;
let opts = WriteOptions::default().with_compression(None);
assert_eq!(opts.compression, None);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.compression: Option<u8>Deflate (gzip) level for numeric array datasets, must be in 0..=9.
None writes arrays uncompressed. Values above 9 are rejected; use
Self::with_compression to clamp automatically.
Three kinds of dataset are never compressed regardless of this setting:
- Scalars. HDF5 cannot chunk them, and chunking is a prerequisite for any filter.
- Empty arrays — any tensor with a zero-length axis. There are no bytes to compress, and a filter would still cost a chunked layout.
- String arrays —
edgesandMetadataValue::StringList. These are variable-length, so the dataset holds only heap descriptors and the characters live on HDF5’s global heap. A filter applies to the descriptors, not to the payload, so deflating them would add chunking overhead while compressing almost nothing.
version: Option<String>Version string to write, overriding NirGraph::version.
validate: boolRun NirGraph::validate_structure and lossless-representation checks
before writing. Defaults to true.
Set this to false to rewrite a graph whose edges do not all resolve,
or that contains values the wire format cannot preserve (nested graph
versions, rank-0 metadata tensors). Such files exist in the wild —
upstream’s own braille_noDelay_bias_zero_subgraph.nir has a subgraph
edge naming a node that is not in that subgraph — and read loads
them faithfully, so writing them back has to be possible. The resulting
file will not load in Python nir.read with its default type checking,
and may lose or change the unrepresentable values on readback.
Implementations§
Source§impl WriteOptions
impl WriteOptions
Sourcepub fn with_compression(self, level: Option<u8>) -> Self
pub fn with_compression(self, level: Option<u8>) -> Self
Set the deflate level for array datasets; None disables compression.
Sourcepub fn with_version(self, version: impl Into<String>) -> Self
pub fn with_version(self, version: impl Into<String>) -> Self
Override the version string written to /version.
Sourcepub fn with_validation(self, validate: bool) -> Self
pub fn with_validation(self, validate: bool) -> Self
Enable or disable the pre-write structure check.
Trait Implementations§
Source§impl Clone for WriteOptions
impl Clone for WriteOptions
Source§fn clone(&self) -> WriteOptions
fn clone(&self) -> WriteOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WriteOptions
impl Debug for WriteOptions
Source§impl Default for WriteOptions
impl Default for WriteOptions
impl Eq for WriteOptions
Source§impl PartialEq for WriteOptions
impl PartialEq for WriteOptions
impl StructuralPartialEq for WriteOptions
Auto Trait Implementations§
impl Freeze for WriteOptions
impl RefUnwindSafe for WriteOptions
impl Send for WriteOptions
impl Sync for WriteOptions
impl Unpin for WriteOptions
impl UnsafeUnpin for WriteOptions
impl UnwindSafe for WriteOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
key and return true if they are equal.