Struct OxidationState
pub struct OxidationState { /* private fields */ }Expand description
A validated oxidation-state value.
Implementations§
§impl OxidationState
impl OxidationState
pub const fn new(
sign: OxidationSign,
magnitude: OxidationMagnitude,
) -> Result<OxidationState, OxidationStateValidationError>
pub const fn new( sign: OxidationSign, magnitude: OxidationMagnitude, ) -> Result<OxidationState, OxidationStateValidationError>
Creates an oxidation state from a sign and magnitude.
§Errors
Returns OxidationStateValidationError::ZeroSignedMagnitude when a positive or
negative state uses zero magnitude, or
OxidationStateValidationError::NonZeroZeroMagnitude when a zero state uses a
nonzero magnitude.
pub fn positive(
magnitude: u8,
) -> Result<OxidationState, OxidationStateValidationError>
pub fn positive( magnitude: u8, ) -> Result<OxidationState, OxidationStateValidationError>
Creates a positive oxidation state.
§Errors
Returns OxidationStateValidationError::ZeroSignedMagnitude when magnitude is
zero, or OxidationStateValidationError::MagnitudeAboveMaximum when it is above
the supported range.
pub fn negative(
magnitude: u8,
) -> Result<OxidationState, OxidationStateValidationError>
pub fn negative( magnitude: u8, ) -> Result<OxidationState, OxidationStateValidationError>
Creates a negative oxidation state.
§Errors
Returns OxidationStateValidationError::ZeroSignedMagnitude when magnitude is
zero, or OxidationStateValidationError::MagnitudeAboveMaximum when it is above
the supported range.
pub const fn zero() -> OxidationState
pub const fn zero() -> OxidationState
Creates a zero oxidation state.
pub const fn sign(self) -> OxidationSign
pub const fn sign(self) -> OxidationSign
Returns the oxidation-state sign.
pub const fn magnitude(self) -> OxidationMagnitude
pub const fn magnitude(self) -> OxidationMagnitude
Returns the oxidation-state magnitude.
pub const fn magnitude_value(self) -> u8
pub const fn magnitude_value(self) -> u8
Returns the oxidation-state magnitude value.
pub const fn signed_value(self) -> i8
pub const fn signed_value(self) -> i8
Returns the signed oxidation-state value.
pub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true for positive oxidation states.
pub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true for negative oxidation states.
Trait Implementations§
§impl Clone for OxidationState
impl Clone for OxidationState
§fn clone(&self) -> OxidationState
fn clone(&self) -> OxidationState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more