use objc2::{Message, extern_protocol, msg_send, rc::Retained, runtime::ProtocolObject};
use objc2_foundation::{NSObjectProtocol, NSString};
use crate::{MTLDevice, MTLResourceID};
extern_protocol!(
pub unsafe trait MTLSamplerState: NSObjectProtocol + Send + Sync {
#[unsafe(method(device))]
#[unsafe(method_family = none)]
fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
#[unsafe(method(gpuResourceID))]
#[unsafe(method_family = none)]
fn gpu_resource_id(&self) -> MTLResourceID;
}
);
pub trait MTLSamplerStateExt: MTLSamplerState + Message {
fn label(&self) -> Option<String>
where
Self: Sized,
{
let label: Option<Retained<NSString>> = unsafe { msg_send![self, label] };
label.map(|label| label.to_string())
}
}
impl<T: MTLSamplerState + Message> MTLSamplerStateExt for T {}