pub struct StaticComObject<T>where
T: ComObjectInner,{ /* private fields */ }
Expand description
Enables applications to define COM objects using static storage. This is useful for factory objects, stateless objects, or objects which use need to contain or use mutable global state.
COM objects that are defined using StaticComObject
have their storage placed directly in
static storage; they are not stored in the heap.
COM objects defined using StaticComObject
do have a reference count and this reference
count is adjusted when owned COM interface references (e.g. IFoo
and IUnknown
) are created
for the object. The reference count is initialized to 1.
§Example
ⓘ
#[implement(IFoo)]
struct MyApp {
// ...
}
static MY_STATIC_APP: StaticComObject<MyApp> = MyApp { ... }.into_static();
fn get_my_static_ifoo() -> IFoo {
MY_STATIC_APP.to_interface()
}
Implementations§
Source§impl<T> StaticComObject<T>where
T: ComObjectInner,
impl<T> StaticComObject<T>where
T: ComObjectInner,
Sourcepub const fn from_outer(
outer: <T as ComObjectInner>::Outer,
) -> StaticComObject<T>
pub const fn from_outer( outer: <T as ComObjectInner>::Outer, ) -> StaticComObject<T>
Wraps outer
in a StaticComObject
.
Source§impl<T> StaticComObject<T>where
T: ComObjectInner,
impl<T> StaticComObject<T>where
T: ComObjectInner,
Sourcepub const fn get(&'static self) -> &'static <T as ComObjectInner>::Outer
pub const fn get(&'static self) -> &'static <T as ComObjectInner>::Outer
Gets access to the contained value.
Trait Implementations§
Source§impl<T> Deref for StaticComObject<T>where
T: ComObjectInner,
impl<T> Deref for StaticComObject<T>where
T: ComObjectInner,
Auto Trait Implementations§
impl<T> Freeze for StaticComObject<T>
impl<T> RefUnwindSafe for StaticComObject<T>
impl<T> Send for StaticComObject<T>
impl<T> Sync for StaticComObject<T>
impl<T> Unpin for StaticComObject<T>
impl<T> UnwindSafe for StaticComObject<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more