Skip to main content

Molecule

Struct Molecule 

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

An immutable molecular graph built via MoleculeBuilder.

Representation: atom list + bond list + per-atom adjacency list. No external graph library is used; all graph traversal is domain-aware.

Implementations§

Source§

impl Molecule

Source

pub fn atom_count(&self) -> usize

Number of heavy atoms (does not count implicit H).

Source

pub fn bond_count(&self) -> usize

Number of bonds (edges).

Source

pub fn atom(&self, idx: AtomIdx) -> &Atom

Borrow atom by index.

§Panics

Panics if idx is out of range (should not happen with indices from this molecule).

Source

pub fn bond(&self, idx: BondIdx) -> &BondEntry

Borrow bond by index.

Source

pub fn atoms(&self) -> impl Iterator<Item = (AtomIdx, &Atom)>

Iterate over all atoms as (AtomIdx, &Atom).

Source

pub fn bonds(&self) -> impl Iterator<Item = (BondIdx, &BondEntry)>

Iterate over all bonds as (BondIdx, &BondEntry).

Source

pub fn neighbors( &self, idx: AtomIdx, ) -> impl Iterator<Item = (AtomIdx, BondIdx)> + '_

Iterate over neighbors of idx as (neighbor_atom_idx, bond_idx).

Source

pub fn degree(&self, idx: AtomIdx) -> usize

Degree (number of connected bonds) of atom idx.

Source

pub fn bond_between( &self, a: AtomIdx, b: AtomIdx, ) -> Option<(BondIdx, &BondEntry)>

Return the bond between a and b, or None if not connected.

Source

pub fn formula(&self) -> String

Molecular formula as a Hill-order string (C first, H second, then alphabetical).

Auto Trait Implementations§

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> 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, 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.