pub struct Document { /* private fields */ }Expand description
A whole file, losslessly.
§Examples
use molframe_cif::{Document, parse};
use molframe_core::io::InputBuffer;
let input = InputBuffer::from_bytes(b"data_test\n_entry.id 1ABC\n".to_vec());
let (document, _) = parse(&input)?;
let id = document.first_block().and_then(|block| block.category("entry"))
.and_then(|entry| entry.text("id", 0));
assert_eq!(id, Some("1ABC"));Implementations§
Source§impl Document
impl Document
Sourcepub fn first_block(&self) -> Option<&DataBlock>
pub fn first_block(&self) -> Option<&DataBlock>
The first block, which is the one a single-entry file has.
Sourcepub fn last_block_mut(&mut self) -> Option<&mut DataBlock>
pub fn last_block_mut(&mut self) -> Option<&mut DataBlock>
The last block, which is the one still being filled while parsing.
Sourcepub fn blocks_mut(&mut self) -> impl Iterator<Item = &mut DataBlock>
pub fn blocks_mut(&mut self) -> impl Iterator<Item = &mut DataBlock>
Every block, in order, for taking categories out of them.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more