#[cfg(windows)]
use super::*;
use windows_core::*;
#[cfg(windows)]
#[repr(transparent)]
#[derive(Clone, PartialEq, Eq)]
pub struct AgileSlot(IAgileReference);
#[cfg(not(windows))]
#[repr(transparent)]
#[derive(Clone, PartialEq, Eq)]
pub struct AgileSlot(IUnknown);
impl AgileSlot {
pub fn new<T: Interface>(object: &T) -> Result<Self> {
#[cfg(windows)]
unsafe {
let mut result__ = core::mem::zeroed();
RoGetAgileReference(
AGILEREFERENCE_DEFAULT,
&T::IID,
Interface::as_raw(object) as _,
&mut result__,
)
.and_then(|| Type::from_abi(result__))
.map(Self)
}
#[cfg(not(windows))]
{
object.cast::<IUnknown>().map(Self)
}
}
pub fn resolve<T: Interface>(&self) -> Result<T> {
#[cfg(windows)]
unsafe {
self.0.Resolve()
}
#[cfg(not(windows))]
{
self.0.cast()
}
}
pub fn as_raw(&self) -> *mut core::ffi::c_void {
self.0.as_raw()
}
}
impl core::fmt::Debug for AgileSlot {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
self.0.fmt(f)
}
}