use super::{
BodySelection, BodySelectionError, GeneratedBodyRef, NativeSelections, SelectionMembers,
};
use crate::ids::{FeatureInputTopologyId, HistoricalBodyId};
impl BodySelection {
pub fn local(bodies: Vec<String>, native: String) -> Result<Self, BodySelectionError> {
Ok(Self::Local {
bodies: NativeSelections::try_from(bodies)?,
native: native.try_into()?,
})
}
pub fn historical(
state: FeatureInputTopologyId,
bodies: Vec<HistoricalBodyId>,
native: String,
) -> Result<Self, BodySelectionError> {
Ok(Self::Historical {
state,
bodies: SelectionMembers::try_from(bodies)?,
native: native.try_into()?,
})
}
pub fn generated(
bodies: Vec<GeneratedBodyRef>,
native: String,
) -> Result<Self, BodySelectionError> {
Ok(Self::Generated {
bodies: SelectionMembers::try_from(bodies)?,
native: native.try_into()?,
})
}
}
impl From<BodySelectionError> for cadmpeg_core::CodecError {
fn from(error: BodySelectionError) -> Self {
Self::malformed(error.to_string())
}
}