pub struct WindowHandle<'a> {
raw: RawWindowHandle,
_marker: PhantomData<&'a ()>,
}
Expand description
The handle to a window.
This is the primary return type of the HasWindowHandle
trait. All pointers within this type
are guaranteed to be valid and not dangling for the lifetime of the handle. This excludes window IDs
like XIDs and the window ID for web platforms. See the documentation on the HasWindowHandle
trait for more information about these safety requirements.
This handle is guaranteed to be safe and valid.
Fields§
§raw: RawWindowHandle
§_marker: PhantomData<&'a ()>
Implementations§
§impl<'a> WindowHandle<'a>
impl<'a> WindowHandle<'a>
pub unsafe fn borrow_raw(raw: RawWindowHandle) -> WindowHandle<'a>
pub unsafe fn borrow_raw(raw: RawWindowHandle) -> WindowHandle<'a>
Borrow a WindowHandle
from a RawWindowHandle
.
§Safety
Users can safely assume that non-null
/0
fields are valid handles, and it is up to the
implementer of this trait to ensure that condition is upheld.
Despite that qualification, implementers should still make a best-effort attempt to fill in all available fields. If an implementation doesn’t, and a downstream user needs the field, it should try to derive the field from other fields the implementer does provide via whatever methods the platform provides.
Note that this guarantee only applies to pointers, and not any window ID types in the handle. This includes Window IDs (XIDs) from X11 and the window ID for web platforms. There is no way for Rust to enforce any kind of invariant on these types, since:
- For all three listed platforms, it is possible for safe code in the same process to delete the window.
- For X11, it is possible for code in a different process to delete the window. In fact, it is possible for code on a different machine to delete the window.
It is also possible for the window to be replaced with another, valid-but-different window. User code should be aware of this possibility, and should be ready to soundly handle the possible error conditions that can arise from this.
pub fn as_raw(&self) -> RawWindowHandle
pub fn as_raw(&self) -> RawWindowHandle
Get the underlying raw window handle.
Trait Implementations§
§impl AsRef<RawWindowHandle> for WindowHandle<'_>
impl AsRef<RawWindowHandle> for WindowHandle<'_>
§fn as_ref(&self) -> &RawWindowHandle
fn as_ref(&self) -> &RawWindowHandle
§impl Borrow<RawWindowHandle> for WindowHandle<'_>
impl Borrow<RawWindowHandle> for WindowHandle<'_>
§fn borrow(&self) -> &RawWindowHandle
fn borrow(&self) -> &RawWindowHandle
§impl<'a> Clone for WindowHandle<'a>
impl<'a> Clone for WindowHandle<'a>
§fn clone(&self) -> WindowHandle<'a>
fn clone(&self) -> WindowHandle<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for WindowHandle<'_>
impl Debug for WindowHandle<'_>
§impl From<WindowHandle<'_>> for RawWindowHandle
impl From<WindowHandle<'_>> for RawWindowHandle
§fn from(handle: WindowHandle<'_>) -> RawWindowHandle
fn from(handle: WindowHandle<'_>) -> RawWindowHandle
§impl HasWindowHandle for WindowHandle<'_>
impl HasWindowHandle for WindowHandle<'_>
§fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
§impl<'a> Hash for WindowHandle<'a>
impl<'a> Hash for WindowHandle<'a>
§impl<'a> PartialEq for WindowHandle<'a>
impl<'a> PartialEq for WindowHandle<'a>
§fn eq(&self, other: &WindowHandle<'a>) -> bool
fn eq(&self, other: &WindowHandle<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<'a> Copy for WindowHandle<'a>
impl<'a> Eq for WindowHandle<'a>
impl<'a> StructuralPartialEq for WindowHandle<'a>
Auto Trait Implementations§
impl<'a> Freeze for WindowHandle<'a>
impl<'a> RefUnwindSafe for WindowHandle<'a>
impl<'a> !Send for WindowHandle<'a>
impl<'a> !Sync for WindowHandle<'a>
impl<'a> Unpin for WindowHandle<'a>
impl<'a> UnwindSafe for WindowHandle<'a>
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
§fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
HasWindowHandle
instead§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request