use crate::Error;
use super::connection::Connection;
use metal::Device as MetalDevice;
use std::marker::PhantomData;
#[derive(Clone, Debug)]
pub struct Adapter {
pub(crate) is_low_power: bool,
}
#[derive(Clone)]
pub struct Device {
adapter: Adapter,
phantom: PhantomData<*mut ()>,
}
#[derive(Clone)]
pub struct NativeDevice(pub MetalDevice);
impl Device {
#[inline]
pub(crate) fn new(adapter: Adapter) -> Result<Device, Error> {
Ok(Device { adapter, phantom: PhantomData })
}
pub fn native_device(&self) -> NativeDevice {
NativeDevice(MetalDevice::all().into_iter().filter(|device| {
device.is_low_power() == self.adapter.is_low_power
}).next().expect("No Metal device found!"))
}
#[inline]
pub fn connection(&self) -> Connection {
Connection
}
#[inline]
pub fn adapter(&self) -> Adapter {
self.adapter.clone()
}
}