fips_md/utils/
value.rs

1//! Helper struct for translating between Rust values and FIPS values
2
3use crate::parser::FipsType;
4
5#[derive(Clone)]
6pub enum FipsValue {
7    Double(f64),
8    Int64(i64),
9    // TODO: Array values
10}
11
12impl Into<FipsValue> for f64 {
13    fn into(self) -> FipsValue {
14        FipsValue::Double(self)
15    }
16}
17
18impl Into<FipsValue> for i64 {
19    fn into(self) -> FipsValue {
20        FipsValue::Int64(self)
21    }
22}
23
24impl FipsValue {
25    // Get the corresponding type
26    pub(crate) fn get_type(&self) -> FipsType {
27        match self {
28            Self::Double(_) => FipsType::Double,
29            Self::Int64(_) => FipsType::Int64
30        }
31    }
32
33    pub(crate) fn get_size(&self) -> usize {
34        match self {
35            Self::Double(_) | Self::Int64(_) => std::mem::size_of::<Self>()
36        }
37    }
38}