pub trait AppLike<Helper>where
Self: Sized,{
// Required methods
fn new() -> Result<(Helper, Rc<ReentrantRefCell<Option<Self>>>)>;
fn startup_wnd_proc(
hwnd: HWND,
msg_id: u32,
wparam: WPARAM,
lparam: LPARAM,
) -> (Option<Self>, Option<LRESULT>);
fn wnd_proc(
&mut self,
hwnd: HWND,
msg_id: u32,
wparam: WPARAM,
lparam: LPARAM,
) -> Option<LRESULT>;
// Provided method
fn reenter_wnd_proc<F, T>(&mut self, f: F) -> T
where F: FnOnce(&mut Self) -> T { ... }
}
Required Methods§
Sourcefn new() -> Result<(Helper, Rc<ReentrantRefCell<Option<Self>>>)>
fn new() -> Result<(Helper, Rc<ReentrantRefCell<Option<Self>>>)>
Where you let the helper make your app.
Sourcefn startup_wnd_proc(
hwnd: HWND,
msg_id: u32,
wparam: WPARAM,
lparam: LPARAM,
) -> (Option<Self>, Option<LRESULT>)
fn startup_wnd_proc( hwnd: HWND, msg_id: u32, wparam: WPARAM, lparam: LPARAM, ) -> (Option<Self>, Option<LRESULT>)
The window procedure called initially, until you provide an instance through the first return value. The second return value is as in Self::wnd_proc()
. You can, e.g., create the instance on WM_CREATE
.
Sourcefn wnd_proc(
&mut self,
hwnd: HWND,
msg_id: u32,
wparam: WPARAM,
lparam: LPARAM,
) -> Option<LRESULT>
fn wnd_proc( &mut self, hwnd: HWND, msg_id: u32, wparam: WPARAM, lparam: LPARAM, ) -> Option<LRESULT>
The regular window procedure called when Self::startup_wnd_proc()
isn’t called anymore.
See also [window::WindowClass
].
§Safety
You must use Self::reenter_wnd_proc()
when appropriate.
Provided Methods§
Sourcefn reenter_wnd_proc<F, T>(&mut self, f: F) -> Twhere
F: FnOnce(&mut Self) -> T,
fn reenter_wnd_proc<F, T>(&mut self, f: F) -> Twhere
F: FnOnce(&mut Self) -> T,
A helper function that simply takes the same self
parameter as Self::wnd_proc()
to cause compiler errors, if necessary, when functions are called that synchronously call the window procedure and thus borrow &mut self
again (via ReentrantRefCell
). Anything other than simple reborrowing is against the rules. This prevents multiple simultaneous borrows.
The function can be viewed as adding a self
parameter to Windows API functions, as if they would belong to the type.
See ReentrantRefCell::borrow_mut_reentrant()
for more information.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.