Crates.io | awita |
lib.rs | awita |
version | 0.2.3 |
source | src |
created_at | 2021-08-04 00:00:53.026588 |
updated_at | 2022-01-14 06:02:02.506298 |
description | An asynchronous window library in Rust for Windows |
homepage | |
repository | https://github.com/LNSEAB/awita |
max_upload_size | |
id | 431261 |
size | 111,129 |
An asynchronous window library for Windows
"awita" is an asynchronous window creation and management library for Windows. A window event can be received asynchronously using a receiver.
#[tokio::main]
async main() {
let window = awita::Window::builder()
.title("awita hello")
.build()
.await
.unwrap();
let mut closed = window.closed_receiver().await;
loop {
tokio::select! {
Ok(_) = closed.recv() => println!("closed"),
_ = awita::UiThread::join() => break,
}
}
awita::UiThread::maybe_unwind().await;
}
#[tokio::main]
async fn main() {
let window = awita::Window::builder()
.title("await non_waiting")
.build()
.await
.unwrap();
let mut resized = window.resized_receiver().await;
let mut closed = window.closed_receiver().await;
tokio::spawn(async move {
loop {
tokio::select! {
Ok(_) = closed.recv() => println!("closed"),
_ = awita::UiThread::join() => break,
}
}
});
tokio::task::spawn_blocking(move || {
while awita::UiThread::is_running() {
// For example, write a rendering code.
if let Ok(Some(size)) = resized.try_recv() {
println!("resized: ({}, {})", size.width, size.height);
}
}
})
.await?;
awita::UiThread::maybe_unwind().await;
}
Copyright (c) 2021 LNSEAB