Skip to content

Commit

Permalink
docs: add basic documentation for AgileReference
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Feb 1, 2022
1 parent a8da9d6 commit e2cfb4a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/libs/windows/src/core/agile_reference.rs
Expand Up @@ -2,19 +2,25 @@ use super::*;
use bindings::*;
use core::marker::PhantomData;

/// A safe wrapper around WinRT interfaces.
///
/// Some interfaces are not marked as agile thus then don't implement [`Send`].
/// These interfaces can be made agile through this `AgileReference`.
pub struct AgileReference<T> {
reference: IAgileReference,
_marker: PhantomData<T>,
}

impl<T: Interface> AgileReference<T> {
/// Creates a new wrapper around the reference
pub fn new<'a>(from_ref: &'a T) -> Result<Self>
where
&'a T: IntoParam<'a, IUnknown>,
{
unsafe { RoGetAgileReference(AGILEREFERENCE_DEFAULT, &T::IID, from_ref).map(|reference| Self { reference, _marker: Default::default() }) }
}

/// Resolves the reference for the current thread.
pub fn resolve(&self) -> Result<T> {
unsafe { self.reference.Resolve() }
}
Expand Down

0 comments on commit e2cfb4a

Please sign in to comment.