/// A type representing an agile reference to a COM/WinRT object. #[repr(transparent)] #[derive(Clone, PartialEq, Eq)] pubstruct AgileReference<T>(imp::IAgileReference, PhantomData<T>);
impl<T: Interface> AgileReference<T> { /// Creates an agile reference to the object. pubfn new(object: &T) -> Result<Self> { // TODO: this assert is required until we can catch this at compile time using an "associated const equality" constraint. // For example, <T: Interface<UNKNOWN = true>> // https://github.com/rust-lang/rust/issues/92827
assert!(T::UNKNOWN); unsafe {
imp::RoGetAgileReference(
imp::AGILEREFERENCE_DEFAULT,
&T::IID,
core::mem::transmute::<&T, &IUnknown>(object),
)
.map(|reference| Self(reference, Default::default()))
}
}
/// Retrieves a proxy to the target of the `AgileReference` object that may safely be used within any thread context in which get is called. pubfn resolve(&self) -> Result<T> { unsafe { self.0.Resolve() }
}
}
unsafeimpl<T: Interface> Send for AgileReference<T> {} unsafeimpl<T: Interface> Sync for AgileReference<T> {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.