Skip to main content

SliceAccess

Trait SliceAccess 

Source
pub trait SliceAccess {
    // Required method
    fn slice_mut<T: EndianCodec>(&mut self, z: usize) -> Result<&mut [T], Error>;
}
Expand description

Trait for writers that provide direct slice access to voxel data.

§Safety Warning

The caller must ensure the type T matches the file’s voxel mode exactly. Using the wrong type will produce incorrect data without any runtime error. For type-safe access, use write_block instead.

Required Methods§

Source

fn slice_mut<T: EndianCodec>(&mut self, z: usize) -> Result<&mut [T], Error>

Get a mutable slice of voxels at the given z-index.

§Example
// Correct: file was created with mode f32
let slice = writer.slice_mut::<f32>(0)?;

// Wrong: undefined behavior if file mode is not i16
let slice = writer.slice_mut::<i16>(0)?; // Don't do this!

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SliceAccess for MmapWriter

Available on crate feature mmap only.
Source§

impl SliceAccess for Writer