Mdoc

Struct Mdoc 

Source
pub struct Mdoc { /* private fields */ }
Expand description

§=========================== Root MDOC (owned, editable)

Implementations§

Source§

impl Mdoc

Source

pub fn from_reader<R: BufRead>(reader: R) -> Result<Self, ParseError>

Streaming parse into an owned, editable MDOC

Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, ParseError>

Source

pub fn header(&self) -> &[HeaderEntry]

Source

pub fn tilt_series(&self) -> &[ZBlock]

Source

pub fn tilt_image(&self, z: usize) -> Option<&ZBlock>

Source

pub fn tilt_image_mut(&mut self, z: usize) -> Option<&mut ZBlock>

Source

pub fn write<W: Write>(&self, w: W) -> Result<()>

Source

pub fn write_lossless<W: Write>(&self, w: W) -> Result<()>

Write with original formatting (lossless round-trip)

This method writes the MDOC file using the original raw values if they were captured, ensuring a true lossless round-trip.

Source§

impl Mdoc

Source

pub fn normalize_spaces(&mut self)

Normalize multiple spaces to single space in all values

Source

pub fn to_json(&self) -> Result<String, Error>

Source

pub fn from_json(json: &str) -> Result<Self, Error>

Source

pub fn normalize_format(&mut self)

Normalize all formats in the MDOC file

This method combines space normalization and key-value format normalization. It handles various input styles and produces a consistent output format.

Handles formats like:

  • Defocus = -5.0; (standard)
  • Defocus=-5.0; (no spaces around =)
  • Defocus = -5.0 (no semicolon)
  • Key = value with spaces; (extra spaces)
  • "Value" (quoted)

Returns normalized format: Key = value;

Note: Raw values are automatically captured during parsing, so lossless round-trip is always available via write_lossless().

Source§

impl Mdoc

Source

pub fn add_tilt_image(&mut self, z: usize) -> &mut ZBlock

Source

pub fn remove_tilt_image(&mut self, z: usize) -> bool

Source

pub fn update_field( &mut self, z: usize, key: impl Into<String>, value: impl Into<String>, ) -> bool

Source

pub fn validate(&self) -> Result<(), Vec<ValidationError>>

Trait Implementations§

Source§

impl Clone for Mdoc

Source§

fn clone(&self) -> Mdoc

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Mdoc

Source§

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

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

impl<'de> Deserialize<'de> for Mdoc

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Mdoc

Source§

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

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

impl Serialize for Mdoc

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Mdoc

§

impl RefUnwindSafe for Mdoc

§

impl Send for Mdoc

§

impl Sync for Mdoc

§

impl Unpin for Mdoc

§

impl UnwindSafe for Mdoc

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,