use strum_macros::EnumString;
#[derive(
Debug, Serialize, PartialEq, Deserialize, Copy, Clone, EnumString, strum_macros::Display,
)]
pub enum OpticAxisType {
PositiveUniaxial,
NegativeUniaxial,
PositiveBiaxial,
NegativeBiaxial,
}
#[allow(non_camel_case_types)]
#[derive(
Debug, Serialize, PartialEq, Deserialize, Copy, Clone, EnumString, strum_macros::Display,
)]
pub enum PointGroup {
HM_1,
HM_i1,
HM_2,
HM_m,
HM_2sm,
HM_222,
HM_mm2,
HM_mmm,
HM_4,
HM_i4,
HM_4sm,
HM_422,
HM_4mm,
HM_i42m,
HM_4smmm,
HM_3,
HM_i3,
HM_32,
HM_3m,
HM_i3m,
HM_6,
HM_i6,
HM_6sm,
HM_622,
HM_6mm,
HM_i62m,
HM_6smmm,
HM_23,
HM_mi3,
HM_432,
HM_i43m,
HM_mi3m,
}
#[derive(Debug, Serialize, PartialEq, Deserialize, Copy, Clone)]
pub struct ValidWavelengthRange(pub f64, pub f64);
#[derive(Debug, Serialize, PartialEq, Deserialize, Copy, Clone)]
pub struct CrystalMeta {
pub id: &'static str,
pub name: &'static str,
pub reference_url: &'static str,
pub axis_type: OpticAxisType,
pub point_group: PointGroup,
pub transmission_range: Option<ValidWavelengthRange>,
pub temperature_dependence_known: bool,
}
#[cfg(feature = "pyo3")]
mod pyo3_impls {
use super::*;
use pyo3::{
prelude::*,
types::{PyDict, PyTuple},
};
impl ToPyObject for ValidWavelengthRange {
fn to_object(&self, py: Python<'_>) -> PyObject {
let tuple = PyTuple::new_bound(py, &[self.0, self.1]);
tuple.into()
}
}
impl ToPyObject for CrystalMeta {
fn to_object(&self, py: Python<'_>) -> PyObject {
let dict = PyDict::new_bound(py);
dict.set_item("id", self.id).unwrap();
dict.set_item("name", self.name).unwrap();
dict.set_item("reference_url", self.reference_url).unwrap();
dict
.set_item("axis_type", self.axis_type.to_string())
.unwrap();
dict
.set_item("point_group", self.point_group.to_string())
.unwrap();
dict
.set_item("transmission_range", self.transmission_range)
.unwrap();
dict
.set_item(
"temperature_dependence_known",
self.temperature_dependence_known,
)
.unwrap();
dict.into()
}
}
impl IntoPy<PyObject> for CrystalMeta {
fn into_py(self, py: Python<'_>) -> PyObject {
self.to_object(py)
}
}
}