pub struct SelectObjectGuard<'a, H, G>{ /* private fields */ }
Available on crate features
kernel
and gdi
only.Expand description
RAII implementation for
HDC::SelectObject
calls, which
automatically selects the previous GDI object at the end of the scope.
Implementations§
Source§impl<'a, H, G> SelectObjectGuard<'a, H, G>
impl<'a, H, G> SelectObjectGuard<'a, H, G>
Sourcepub const unsafe fn new(
hdc: &'a H,
prev_hgdi: G,
region: Option<REGION>,
) -> Self
pub const unsafe fn new( hdc: &'a H, prev_hgdi: G, region: Option<REGION>, ) -> Self
Constructs the guard by taking ownership of the handle.
§Safety
Be sure the handle must be again passed to
HDC::SelectObject
at the end of scope.
Sourcepub const fn prev_object(&self) -> &G
pub const fn prev_object(&self) -> &G
Returns a handle to the object that has been replaced.
Sourcepub const fn region(&self) -> Option<REGION>
pub const fn region(&self) -> Option<REGION>
Returns the region information returned by the source
HDC::SelectObject
call, if
the GdiObject
was an
HRGN
; otherwise returns None
.
Sourcepub fn leak(&mut self) -> G
pub fn leak(&mut self) -> G
Ejects the underlying handle, leaving a
Handle::INVALID
in its place.
Since the internal handle will be invalidated, the destructor will not run. It’s your responsability to run it, otherwise you’ll cause a resource leak.
Trait Implementations§
Auto Trait Implementations§
impl<'a, H, G> Freeze for SelectObjectGuard<'a, H, G>where
G: Freeze,
impl<'a, H, G> RefUnwindSafe for SelectObjectGuard<'a, H, G>where
G: RefUnwindSafe,
H: RefUnwindSafe,
impl<'a, H, G> Send for SelectObjectGuard<'a, H, G>where
H: Sync,
impl<'a, H, G> Sync for SelectObjectGuard<'a, H, G>
impl<'a, H, G> Unpin for SelectObjectGuard<'a, H, G>where
G: Unpin,
impl<'a, H, G> UnwindSafe for SelectObjectGuard<'a, H, G>where
G: UnwindSafe,
H: RefUnwindSafe,
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