[][src]Struct riddle_platform_winit::PlatformSystem

pub struct PlatformSystem { /* fields omitted */ }

The winit platform system core state, along with PlatformMainThreadState.

Mostly used to lookup Window by WindowId, and subscribe to PlatformEvents.

Implementations

impl PlatformSystem[src]

pub fn new() -> (PlatformSystemHandle, PlatformMainThreadState)[src]

Create a new platform system and its main thread state pair.

Do not call if using the riddle crate as recommended, as RiddleLib manages the creation and platform lifetime automatically.

Example

This example is only relevant if you're not using riddle

let (platform_system, main_thread_state) = PlatformSystem::new();
let window = WindowBuilder::new().build(main_thread_state.borrow_context())?;

main_thread_state.run::<PlatformError, _>(move |ctx| {
    match ctx.event() {
        PlatformEvent::WindowClose(_) => { ctx.quit(); }
        _ => ()
    };
    Ok(())
})

pub fn event_pub(&self) -> &EventPub<PlatformEvent>[src]

Get the PlatformEvent publisher, so that other systems can consume events.

Example

let rdl =  RiddleLib::new()?;
let subscriber: EventSub<PlatformEvent> = EventSub::new();

// Attach subscriber to the platform event stream
rdl.state().platform().event_pub().attach(&subscriber);

pub fn lookup_window(&self, window_id: WindowId) -> Option<WindowHandle>[src]

Get a WindowHandle associated with a WindowId, if one exists.

Example

let rdl =  RiddleLib::new()?;
let window = WindowBuilder::new().build(rdl.context())?;
let window_id = window.id();
assert!(WindowHandle::eq(&window,
       &rdl.state().platform().lookup_window(window_id).unwrap()));

Trait Implementations

impl CloneHandle for PlatformSystem[src]

type Handle = PlatformSystemHandle

The type which represents a strong reference, and which may be dereferenced as Self. Read more

type WeakHandle = PlatformSystemWeak

The type which represents a weak reference.

Auto Trait Implementations

impl RefUnwindSafe for PlatformSystem

impl Send for PlatformSystem

impl Sync for PlatformSystem

impl Unpin for PlatformSystem

impl UnwindSafe for PlatformSystem

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.