pub struct Host { /* private fields */ }Expand description
Configuration and callbacks for a window’s host.
§Safety
This type and its methods are always safe to use.
It also brings the additional safety guarantee that all handlers given to this type will be destroyed alongside with the window.
This guarantees callbacks cannot be fired after the Window is dropped.
(or after this Host object is dropped, if it never made it to a
Window::create_with_host call).
Implementations§
Source§impl Host
impl Host
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty host with no callbacks.
Calling Window::create_with_host with this is equivalent
to just calling Window::create.
Sourcepub fn with_main_thread(self, main_thread: impl HostMainThreadCaller) -> Self
pub fn with_main_thread(self, main_thread: impl HostMainThreadCaller) -> Self
Sets the HostMainThreadCaller handler to be used.
If another callback handler was already set, it is replaced.
§Platform Compatibility notes
This is only useful on X11. On Window and macOS, this is a no-op.
Sourcepub fn with_callbacks(self, callbacks: impl HostCallbacks) -> Self
pub fn with_callbacks(self, callbacks: impl HostCallbacks) -> Self
Sets the HostCallbacks handler to be used.
If another callback handler was already set, it is replaced.