[−][src]Struct riddle_platform_winit::PlatformContext
The platform system context provided to the application main thread.
It is used to allow the application to deal with platform events, and perform actions which must be done on the main thread (eg. creating windows).
To acquire a context when using riddle
(the recommended approach):
RiddleLib::context()
returns aRiddleContext
which implementsBorrow<PlatformContext>
.RiddleLib::run()
passes aRiddleContext
to the application callback.
To acquire a context when using this crate directly:
PlatformMainThreadState::borrow_context()
PlatformMainThreadState::run
passes it to application callback
Example
use riddle::{*, platform::*}; fn main() -> Result<(), RiddleError> { let rdl = RiddleLib::new()?; // Get a context before the application starts the main event loop. let window_a: WindowHandle = WindowBuilder::new().build(rdl.context())?; let mut window_b: Option<WindowHandle> = None; rdl.run(move |rdl| { if window_b.is_none() { // rdl: RiddleContext, is used to build the second window. window_b = Some(WindowBuilder::new().build(rdl).unwrap()); } else { rdl.quit(); } }) }
Implementations
impl<'a> PlatformContext<'a>
[src]
pub fn quit(&self) -> Result<(), PlatformError>
[src]
Issue a quit request to the underlying platform system.
The application will quit when that message is processed by the main event loop.
pub fn event(&self) -> &PlatformEvent
[src]
Get the event associated with the context.
This will be the platform event that triggered the application closure, or
PlatformEvent::Unknown
if the context was created before the main event loop
has started.
pub fn system(&self) -> &PlatformSystem
[src]
The platform system associated with this context.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for PlatformContext<'a>
impl<'a> !Send for PlatformContext<'a>
impl<'a> !Sync for PlatformContext<'a>
impl<'a> Unpin for PlatformContext<'a>
impl<'a> !UnwindSafe for PlatformContext<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,