use std::io::Read;
use prost::Message;
use crate::io::generated::stratiphy_model::Cohort as PbCohort;
use crate::io::generated::stratiphy_workflow::StratiphyResult as PbStratiphyResult;
use crate::model::Cohort;
use crate::workflow::StratiphyResult;
pub fn parse_stratiphy_result(mut read: impl Read) -> Result<StratiphyResult, String> {
let mut buf = Vec::new();
read.read_to_end(&mut buf).map_err(|e| e.to_string())?;
match PbStratiphyResult::decode(&buf[..]) {
Ok(msg) => StratiphyResult::try_from(msg),
Err(err) => Err(err.to_string()),
}
}
pub fn parse_cohort(mut read: impl Read) -> Result<Cohort, String> {
let mut buf = Vec::new();
read.read_to_end(&mut buf).map_err(|e| e.to_string())?;
match PbCohort::decode(&buf[..]) {
Ok(msg) => Cohort::try_from(msg),
Err(err) => Err(err.to_string()),
}
}