pub struct StructureView { /* private fields */ }Expand description
A zero-copy subset of a structure.
§Examples
use molframe_core::structure::{Structure, StructureData};
use molframe_core::AtomSelection;
let structure = Structure::new(StructureData::empty());
let everything = structure.view();
let nothing = everything.narrow(&AtomSelection::Empty);
assert!(nothing.is_empty());
assert_eq!(everything.len(), u64::from(structure.atom_count()));Implementations§
Source§impl StructureView
impl StructureView
Sourcepub fn new(structure: &Structure, atoms: AtomSelection) -> StructureView
pub fn new(structure: &Structure, atoms: AtomSelection) -> StructureView
Creates a view over atoms of structure.
Sourcepub const fn selection(&self) -> &AtomSelection
pub const fn selection(&self) -> &AtomSelection
The atoms this view covers.
Sourcepub fn data(&self) -> &StructureData
pub fn data(&self) -> &StructureData
The structure this view is over.
Sourcepub const fn generation(&self) -> CoordinateGeneration
pub const fn generation(&self) -> CoordinateGeneration
The generation this view was made against.
Sourcepub fn is_stale_for(&self, structure: &Structure) -> bool
pub fn is_stale_for(&self, structure: &Structure) -> bool
Returns true when structure has moved on since this view was made.
A view of an earlier snapshot is still perfectly usable against that snapshot — it holds its own reference to it. This asks a different question: whether the view may be used to talk about the newer one.
Sourcepub fn narrow(&self, other: &AtomSelection) -> StructureView
pub fn narrow(&self, other: &AtomSelection) -> StructureView
A view of the atoms in both this view and other.
Sourcepub fn union(&self, other: &StructureView) -> StructureView
pub fn union(&self, other: &StructureView) -> StructureView
A view of the atoms in either this view or other.
Sourcepub fn intersect(&self, other: &StructureView) -> StructureView
pub fn intersect(&self, other: &StructureView) -> StructureView
A view of the atoms in both views.
Sourcepub fn difference(&self, other: &StructureView) -> StructureView
pub fn difference(&self, other: &StructureView) -> StructureView
A view of the atoms in this view but not the other.
Sourcepub fn positions(&self, model: ModelIndex) -> impl Iterator<Item = [f32; 3]>
pub fn positions(&self, model: ModelIndex) -> impl Iterator<Item = [f32; 3]>
The positions of the covered atoms in one model.
Yields values rather than a slice: the atoms of a view are not in general contiguous, so a slice would either be a lie or a copy.
Sourcepub fn bounds(&self, model: ModelIndex) -> Aabb
pub fn bounds(&self, model: ModelIndex) -> Aabb
The box enclosing the covered atoms in one model.
Trait Implementations§
Source§impl Clone for StructureView
impl Clone for StructureView
Source§fn clone(&self) -> StructureView
fn clone(&self) -> StructureView
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StructureView
impl Debug for StructureView
Source§impl From<StructureView> for Selection
impl From<StructureView> for Selection
Source§fn from(view: StructureView) -> Self
fn from(view: StructureView) -> Self
Auto Trait Implementations§
impl Freeze for StructureView
impl RefUnwindSafe for StructureView
impl Send for StructureView
impl Sync for StructureView
impl Unpin for StructureView
impl UnsafeUnpin for StructureView
impl UnwindSafe for StructureView
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
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> ⓘ
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> ⓘ
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