pub struct ZBlock { /* private fields */ }Expand description
§=========================== Z Block (Tilt Image collection metadata)
Implementations§
Source§impl ZBlock
impl ZBlock
pub fn z(&self) -> usize
pub fn get_raw(&self, key: &str) -> Option<&str>
pub fn get<T: FromMdocValue>(&self, key: &str) -> Option<T>
pub fn set(&mut self, key: impl Into<String>, value: impl Into<String>)
Sourcepub fn remove(&mut self, key: &str) -> bool
pub fn remove(&mut self, key: &str) -> bool
Remove a field by key
Performance note: For single removal, this method has O(n + m) complexity
where n is the number of fields and m is the index size. For batch removals,
use retain_fields() which only rebuilds the index once.
§Performance Comparison
Single removal (10 fields): O(10 + 10) = O(20) Batch removal of 5 fields: 5 × O(10 + 10) = O(100) Using retain_fields() for 5 fields: O(10 + 10) = O(20)
§Example
ⓘ
// ❌ Inefficient for multiple removals
block.remove("Field1");
block.remove("Field2");
block.remove("Field3");
// ✅ Efficient for batch removals
block.retain_fields(|k| k != "Field1" && k != "Field2" && k != "Field3");Sourcepub fn retain_fields<F>(&mut self, f: F)
pub fn retain_fields<F>(&mut self, f: F)
Retain only fields matching the predicate (batch operation)
This is the preferred method for removing multiple fields at once, as it only rebuilds the index once regardless of how many fields are removed.
§Performance
- Time complexity: O(n + m) where n = fields, m = index size
- Index rebuild: Only once, regardless of number of removals
- Space complexity: O(m)
§Example
ⓘ
// Remove multiple fields efficiently
let fields_to_remove = ["Field1", "Field2", "Field3"];
block.retain_fields(|k| !fields_to_remove.contains(&k));Sourcepub fn has_raw_lines(&self) -> bool
pub fn has_raw_lines(&self) -> bool
Check if raw field lines are available for lossless round-trip
Sourcepub fn get_raw_line(&self, key: &str) -> Option<&str>
pub fn get_raw_line(&self, key: &str) -> Option<&str>
Get the original raw field line for a specific key
pub fn tilt_angle(&self) -> Option<f32>
pub fn defocus(&self) -> Option<f32>
pub fn magnification(&self) -> Option<i32>
pub fn subframe_path(&self) -> Option<String>
pub fn basename(&self) -> Option<String>
pub fn stage_position(&self) -> Option<(f32, f32)>
pub fn min_max_mean(&self) -> Option<(f32, f32, f32)>
Sourcepub fn get_checked<T: FromMdocValue>(&self, key: &str) -> Result<T, FieldError>
pub fn get_checked<T: FromMdocValue>(&self, key: &str) -> Result<T, FieldError>
Get field with explicit error handling
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ZBlock
impl<'de> Deserialize<'de> for ZBlock
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ZBlock
impl RefUnwindSafe for ZBlock
impl Send for ZBlock
impl Sync for ZBlock
impl Unpin for ZBlock
impl UnwindSafe for ZBlock
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
Mutably borrows from an owned value. Read more