[][src]Struct chemfiles::Atom

pub struct Atom { /* fields omitted */ }

An Atom is a particle in the current Frame. It stores the following atomic properties:

The atom name is usually an unique identifier (H1, C_a) while the atom type will be shared between all particles of the same type: H, Ow, CH3.

Methods

impl Atom
[src]

Create an atom with the given name, and set the atom type to name.

Example

let atom = Atom::new("He").unwrap();
assert_eq!(atom.name(), Ok(String::from("He")));

Get the atom mass, in atomic mass units.

Example

let atom = Atom::new("He").unwrap();
assert_eq!(atom.mass(), Ok(4.002602));

Set the atom mass to mass, in atomic mass units.

Example

let mut atom = Atom::new("He").unwrap();

atom.set_mass(34.9).unwrap();
assert_eq!(atom.mass(), Ok(34.9));

Get the atom charge, in number of the electron charge e.

Example

let atom = Atom::new("He").unwrap();
assert_eq!(atom.charge(), Ok(0.0));

Set the atom charge to charge, in number of the electron charge e.

Example

let mut atom = Atom::new("He").unwrap();

atom.set_charge(-2.0).unwrap();
assert_eq!(atom.charge(), Ok(-2.0));

Get the atom name.

Example

let atom = Atom::new("He").unwrap();
assert_eq!(atom.name(), Ok(String::from("He")));

Get the atom type.

Example

let atom = Atom::new("He").unwrap();
assert_eq!(atom.atomic_type(), Ok(String::from("He")));

Set the atom name to name.

Example

let mut atom = Atom::new("He").unwrap();

atom.set_name("Zn3").unwrap();
assert_eq!(atom.name(), Ok(String::from("Zn3")));

Set the atom type to atomic_type.

Example

let mut atom = Atom::new("He").unwrap();

atom.set_atomic_type("F").unwrap();
assert_eq!(atom.atomic_type(), Ok(String::from("F")));

Try to get the full name of the atom from the atomic type. For example, the full name of "He" is "Helium", and so on. If the name can not be found, this function returns the empty string.

Example

let atom = Atom::new("Zn").unwrap();
assert_eq!(atom.full_name(), Ok(String::from("Zinc")));

Try to get the Van der Waals radius of the atom from the atomic type. If the radius can not be found, returns -1.

Example

let atom = Atom::new("He").unwrap();
assert_eq!(atom.vdw_radius(), Ok(1.4));

Try to get the covalent radius of the atom from the atomic type. If the radius can not be found, returns -1.

Example

let atom = Atom::new("He").unwrap();
assert_eq!(atom.covalent_radius(), Ok(0.32));

Try to get the atomic number of the atom from the atomic type. If the number can not be found, returns -1.

Example

let atom = Atom::new("He").unwrap();
assert_eq!(atom.atomic_number(), Ok(2));

Add a new property with the given name to this atom.

If a property with the same name already exists, this function override the existing property with the new one.

Examples

let mut atom = Atom::new("He").unwrap();
atom.set("a bool value", Property::Bool(true));

assert_eq!(atom.get("a bool value").unwrap(), Some(Property::Bool(true)));

Get a property with the given name in this atom, if it exist.

Examples

let mut atom = Atom::new("He").unwrap();
atom.set("foo", Property::Double(22.2));

assert_eq!(atom.get("foo").unwrap(), Some(Property::Double(22.2)));
assert_eq!(atom.get("Bar").unwrap(), None);

Trait Implementations

impl Drop for Atom
[src]

Executes the destructor for this type. Read more

impl Clone for Atom
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl !Send for Atom

impl !Sync for Atom

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.