#[allow(unused_imports)]
use crate::platform::EnabledTernary;
use crate::{errors::TargetSpecError, platform::Platform};
use std::sync::Arc;
#[derive(Clone, Debug)]
#[non_exhaustive]
pub enum PlatformSpec {
Always,
Platforms(Vec<Arc<Platform>>),
Any,
}
impl PlatformSpec {
pub fn build_target() -> Result<Self, TargetSpecError> {
Ok(PlatformSpec::from(Platform::build_target()?))
}
pub fn platforms<I, P>(platforms: I) -> Self
where
I: IntoIterator<Item = P>,
P: Into<Arc<Platform>>,
{
PlatformSpec::Platforms(
platforms
.into_iter()
.map(|platform| platform.into())
.collect(),
)
}
}
impl<T: Into<Arc<Platform>>> From<T> for PlatformSpec {
#[inline]
fn from(platform: T) -> Self {
PlatformSpec::Platforms(vec![platform.into()])
}
}