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 typeIAEA symbolSpecialData variant
alphaaAlpha
beta plusbpBetaPlus
beta minusbmBetaMinus
gammagGamma
electroneElectron
x-rayxXray

§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

pub fn is_isomer(&self) -> bool

Check if the parent is in an excited state

pub fn parent_name(&self) -> String

Common formatting for the parent nuclide

pub fn daughter_name(&self) -> String

Common formatting for the daughter nuclide

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 Clone for Record

§

fn clone(&self) -> Record

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Record

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Record

§

fn default() -> Record

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for Record
where Record: Default,

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Record, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for Record

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Serialize for Record

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,