Skip to main content

StaticComObject

Struct StaticComObject 

pub struct StaticComObject<T>
where T: ComObjectInner,
{ /* private fields */ }
Expand description

Stores a COM object in static memory.

Its reference count starts at one and tracks owned interface references. Access the object through Self::get, which requires static storage so interfaces cannot outlive the object.

ⓘ
use windows_core::*;
interface_decl! {
    unsafe trait IFoo(IFoo_Vtbl, IFoo_Impl): IUnknown
        = 0x094d70d6_5202_44b8_abb8_43860da5aca2 {}
}
struct Foo;
implement_decl! { impl Foo as Foo_Impl: [IFoo] }
impl IFoo_Impl for Foo_Impl {}
let local = Foo.into_static();
let interface: IFoo = local.to_interface();
drop(local);
ⓘ
use windows_core::*;
interface_decl! {
    unsafe trait IFoo(IFoo_Vtbl, IFoo_Impl): IUnknown
        = 0x094d70d6_5202_44b8_abb8_43860da5aca2 {}
}
struct Foo;
implement_decl! { impl Foo as Foo_Impl: [IFoo] }
impl IFoo_Impl for Foo_Impl {}
let local = Foo.into_static();
let interface: IFoo = local.get().to_interface();
drop(local);

Implementations§

§

impl<T> StaticComObject<T>
where T: ComObjectInner,

pub const fn from_outer(outer: T::Outer) -> Self

Wraps outer in a StaticComObject.

§

impl<T> StaticComObject<T>
where T: ComObjectInner,

pub const fn get(&'static self) -> &'static T::Outer

Gets access to the contained value.

Auto Trait Implementations§

§

impl<T> Forget for StaticComObject<T>

§

impl<T> Freeze for StaticComObject<T>
where <T as ComObjectInner>::Outer: Freeze,

§

impl<T> Move for StaticComObject<T>

§

impl<T> RefUnwindSafe for StaticComObject<T>

§

impl<T> Send for StaticComObject<T>
where <T as ComObjectInner>::Outer: Send,

§

impl<T> Sync for StaticComObject<T>
where <T as ComObjectInner>::Outer: Sync,

§

impl<T> Unpin for StaticComObject<T>
where <T as ComObjectInner>::Outer: Unpin,

§

impl<T> UnsafeUnpin for StaticComObject<T>

§

impl<T> UnwindSafe for StaticComObject<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.