pub struct ChunkBuilder { /* private fields */ }Expand description
Accumulates atoms and closes chunks at residue boundaries.
Rows are appended in file order. A chunk is closed once it is at or past the target size and the next atom starts a new residue, which is what keeps the no-straddling guarantee without splitting a large residue.
§Examples
use molframe_core::chunk::{AtomRecord, ChunkBuilder};
use molframe_core::{AltId, Element, OptionalSymbol, Presence, ResidueIndex, SymbolId};
let mut builder = ChunkBuilder::new();
builder.push(AtomRecord {
position: Some([1.0, 2.0, 3.0]),
element: Element::CARBON,
atom_name: SymbolId::from_raw(0),
auth_atom_name: OptionalSymbol::NONE,
alternate_component_id: OptionalSymbol::NONE,
alt_id: AltId::BLANK,
residue: ResidueIndex::new(0),
occupancy: (1.0, Presence::Present),
b_factor: (12.5, Presence::Present),
formal_charge: (0, Presence::Inapplicable),
atom_site_id: 1,
});
let (chunks, coords) = builder.finish();
assert_eq!(chunks.len(), 1);
assert_eq!(coords.len(), 1);
assert!(chunks[0].stats().elements.contains(Element::CARBON));Implementations§
Source§impl ChunkBuilder
impl ChunkBuilder
Sourcepub fn with_target(target: u32) -> Self
pub fn with_target(target: u32) -> Self
Creates a builder that closes chunks at target atoms.
Exists for tests and for callers that know their access pattern; the default is what a file read uses.
Sourcepub fn start_model(&mut self, model: u32)
pub fn start_model(&mut self, model: u32)
Declares which model the atoms that follow belong to.
Closes the current chunk, because a chunk’s model is constant by construction and that is what lets the column vanish entirely.
Sourcepub fn push(&mut self, record: AtomRecord)
pub fn push(&mut self, record: AtomRecord)
Appends an atom.
Sourcepub fn finish(self) -> (Vec<AtomChunk>, CoordinateBlock)
pub fn finish(self) -> (Vec<AtomChunk>, CoordinateBlock)
Closes the last chunk and returns everything built.
Trait Implementations§
Source§impl Debug for ChunkBuilder
impl Debug for ChunkBuilder
Auto Trait Implementations§
impl Freeze for ChunkBuilder
impl RefUnwindSafe for ChunkBuilder
impl Send for ChunkBuilder
impl Sync for ChunkBuilder
impl Unpin for ChunkBuilder
impl UnsafeUnpin for ChunkBuilder
impl UnwindSafe for ChunkBuilder
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> 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