pub mod array;
pub mod genotype;
use std::io;
pub use self::{array::Array, genotype::Genotype};
#[derive(Debug)]
pub enum Value<'a> {
Integer(i32),
Float(f32),
Character(char),
String(&'a str),
Genotype(Box<dyn Genotype + 'a>),
Array(Array<'a>),
}
impl<'a> TryFrom<Value<'a>> for crate::variant::record_buf::samples::sample::Value {
type Error = io::Error;
fn try_from(value: Value<'a>) -> Result<Self, Self::Error> {
match value {
Value::Integer(n) => Ok(Self::Integer(n)),
Value::Float(n) => Ok(Self::Float(n)),
Value::Character(c) => Ok(Self::Character(c)),
Value::String(s) => Ok(Self::String(s.into())),
Value::Genotype(genotype) => genotype.as_ref().try_into().map(Self::Genotype),
Value::Array(array) => array.try_into().map(Self::Array),
}
}
}