noodles_vcf/variant/record/samples/series/
value.rs1pub mod array;
4pub mod genotype;
5
6use std::{borrow::Cow, io};
7
8pub use self::{array::Array, genotype::Genotype};
9
10#[derive(Debug)]
12pub enum Value<'a> {
13 Integer(i32),
15 Float(f32),
17 Character(char),
19 String(Cow<'a, str>),
21 Genotype(Box<dyn Genotype + 'a>),
23 Array(Array<'a>),
25}
26
27impl<'a> TryFrom<Value<'a>> for crate::variant::record_buf::samples::sample::Value {
28 type Error = io::Error;
29
30 fn try_from(value: Value<'a>) -> Result<Self, Self::Error> {
31 match value {
32 Value::Integer(n) => Ok(Self::Integer(n)),
33 Value::Float(n) => Ok(Self::Float(n)),
34 Value::Character(c) => Ok(Self::Character(c)),
35 Value::String(s) => Ok(Self::String(s.into())),
36 Value::Genotype(genotype) => genotype.as_ref().try_into().map(Self::Genotype),
37 Value::Array(array) => array.try_into().map(Self::Array),
38 }
39 }
40}