Struct Record
#[repr(C)]pub struct Record {Show 21 fields
pub energy: Option<f32>,
pub unc_en: Option<f32>,
pub intensity: Option<f32>,
pub unc_i: Option<f32>,
pub half_life: Option<f32>,
pub unc_hls: Option<f32>,
pub decay_mode: Option<String>,
pub branching: Option<f32>,
pub unc_b: Option<f32>,
pub jp: Option<String>,
pub q: Option<String>,
pub unc_q: Option<String>,
pub p_symbol: Option<String>,
pub p_z: Option<u8>,
pub p_n: Option<u8>,
pub p_energy: Option<f32>,
pub unc_pe: Option<String>,
pub d_symbol: Option<String>,
pub d_z: Option<u8>,
pub d_n: Option<u8>,
pub special_data: SpecialData,
}
Expand description
Data for a single record from an IAEA fetch request
This is almost a mirror of the decay_rads
data from the IAEA chart of
nuclides API (see the
guide).
§Why Option?
The guide is frustratingly inconsistent with the data you actually recieve and unfortunately every CSV field appears optional.
For absolute transparency the data remain the standard Option type
indicating the presence of either Some
where an entry is valid, or None
for blank empty fields.
§Special decay data
Any decay_rads
request to the IAEA chart of nuclides returns the common
fields seen in a Record regardless of radiation type.
Every decay radiation type will also have additional specialised data. To
keep everything under a common and simple interface, every Record stores
these data undert the special_data
field.
The table below is a reference of all supported types but should be fairly intuitive.
Decay radiation type | IAEA symbol | SpecialData variant |
---|---|---|
alpha | a | Alpha |
beta plus | bp | BetaPlus |
beta minus | bm | BetaMinus |
gamma | g | Gamma |
electron | e | Electron |
x-ray | x | Xray |
§Examples
§Basic use
Fetching the data directly from the IAEA API will always use a fetch_*
function.
For example, the cobalt-60 decay data for gamma emissions:
// Get all records for the Cobalt-60 nuclide
let records = fetch_nuclide("co60", RadType::Gamma).unwrap();
// Find the 1173 keV emission as an example
let example = records
.into_iter()
.find(|record| record.energy.unwrap() == 1173.228)
.unwrap();
// Print a summary of the record
println!("{example}");
The output of which will be the following data. Note the use of an explicit
None
for any blank entires recieved from the IAEA data.
Record
--- Common decay_rads data ---
Energy 1173.228 +/- 0.003 keV
Intensity 99.85 +/- 0.03 %
Half life 166344200 +/- 12096 s
Decay mode B-
Branching 100 +/- None %
State 5+
Q value 2822.81 +/- 21 keV
Parent symbol Co
Parent z 27
Parent n 33
Parent energy 0 +/- None keV
Daughter symbol Ni
Daughter z 28
Daughter n 32
--- Gamma special data ---
Start level 2505.748 keV
End level 1332.508 keV
Multipolarity E2(+M3)
Mixing ratio -0.0025 +/- 22
Conversion coef. 0.0001722 +/- None
§Other formatting options
This can be written to JSON formats fairly easily, continuing on from the previous example:
// Print a JSON string representation of the record
println!("{}", example.to_json().unwrap());
which will result in
{
"energy": 1173.228,
"unc_en": 0.003,
"intensity": 99.85,
"unc_i": 0.03,
"half_life_sec": 166344200.0,
"unc_hls": 12096.0,
"decay": "B-",
"decay_%": 100.0,
"unc_d": null,
"jp": "5+",
"q": "2822.81",
"unc_q": "21",
"p_symbol": "Co",
"p_z": 27,
"p_n": 33,
"p_energy": 0.0,
"unc_pe": null,
"d_symbol": "Ni",
"d_z": 28,
"d_n": 32
"Gamma": {
"start_level_energy": 2505.748,
"end_level_energy": 1332.508,
"multipolarity": "E2(+M3)",
"mixing_ratio": -0.0025,
"unc_mr": 22.0,
"conversion_coeff": 0.0001722,
"unc_cc": null
}
}
Fields§
§energy: Option<f32>
Radiation energy (keV)
unc_en: Option<f32>
Uncertainty in radiation energy (keV)
intensity: Option<f32>
Radiation intensity (%)
unc_i: Option<f32>
Uncertainty in radiation intensity (%)
half_life: Option<f32>
Parent half-life (s)
unc_hls: Option<f32>
Uncertainty in parent half-life (s)
decay_mode: Option<String>
Decay mechanism
branching: Option<f32>
Decay mechanism branching ratio (%)
unc_b: Option<f32>
Decay mechanism branching ratio uncertainty
jp: Option<String>
Nuclear state of the parent nuclide
q: Option<String>
Q-value (keV)
unc_q: Option<String>
Q-value uncertainty (%)
p_symbol: Option<String>
Element of the parent
p_z: Option<u8>
Parent proton number
p_n: Option<u8>
Parent neutron number
p_energy: Option<f32>
Parent energy state (keV)
unc_pe: Option<String>
Uncertainty in parent energy state (keV)
d_symbol: Option<String>
Element of the Daughter
d_z: Option<u8>
Daughter proton number
d_n: Option<u8>
Daughter neutron number
special_data: SpecialData
Data specific to the radiation type requested
Implementations§
§impl Record
impl Record
pub fn parent_name(&self) -> String
pub fn parent_name(&self) -> String
Common formatting for the parent nuclide
pub fn daughter_name(&self) -> String
pub fn daughter_name(&self) -> String
Common formatting for the daughter nuclide
pub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Serailize to JSON format string
// Get all records for the Cobalt-60 nuclide
let co60_records = fetch_nuclide("co60", RadType::Gamma).unwrap();
// Find the 1173 keV emission as an example
let example = co60_records
.iter()
.find(|record| record.energy.unwrap() == 1173.228).unwrap();
// Print a summary of the record
println!("{}", example.to_json().unwrap());
Trait Implementations§
§impl<'de> Deserialize<'de> for Record
impl<'de> Deserialize<'de> for Record
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Record, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Record, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Record
impl Serialize for Record
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnwindSafe for Record
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.