use std::io;
use super::series::Value;
use crate::Header;
pub trait Sample {
fn get<'a, 'h: 'a>(
&'a self,
header: &'h Header,
key: &str,
) -> Option<io::Result<Option<Value<'a>>>>;
fn get_index<'a, 'h: 'a>(
&'a self,
header: &'h Header,
i: usize,
) -> Option<io::Result<Option<Value<'a>>>>;
fn iter<'a, 'h: 'a>(
&'a self,
header: &'h Header,
) -> Box<dyn Iterator<Item = io::Result<(&'a str, Option<Value<'a>>)>> + 'a>;
}
impl Sample for Box<dyn Sample + '_> {
fn get<'a, 'h: 'a>(
&'a self,
header: &'h Header,
key: &str,
) -> Option<io::Result<Option<Value<'a>>>> {
(**self).get(header, key)
}
fn get_index<'a, 'h: 'a>(
&'a self,
header: &'h Header,
i: usize,
) -> Option<io::Result<Option<Value<'a>>>> {
(**self).get_index(header, i)
}
fn iter<'a, 'h: 'a>(
&'a self,
header: &'h Header,
) -> Box<dyn Iterator<Item = io::Result<(&'a str, Option<Value<'a>>)>> + 'a> {
(**self).iter(header)
}
}