[][src]Struct riddle_platform_winit::PlatformContext

pub struct PlatformContext<'a> { /* fields omitted */ }

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):

To acquire a context when using this crate directly:

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.