| Crates.io | sdl3-main |
| lib.rs | sdl3-main |
| version | 0.5.4 |
| created_at | 2024-11-17 00:11:44.393761+00 |
| updated_at | 2025-05-27 15:40:26.750457+00 |
| description | Tools for using SDL's main and callback APIs |
| homepage | |
| repository | https://github.com/maia-s/sdl3-sys-rs |
| max_upload_size | |
| id | 1450739 |
| size | 101,016 |
This crate provides tools for using SDL 3's main and callback APIs, and for interfacing with the main thread of the process.
To provide your own main but call it through SDL, use the main attribute macro.
See the documentation for that for more information.
To use the SDL callback API, you can use either the app_impl attribute macro,
or all four of the app_init, app_iterate, app_event and app_quit
attribute macros. Don't use the main attribute macro in this mode.
See the documentation for more information.
Some SDL functions have to be called on the main thread of the process. This crate provides some helper types and functions to alleviate this.
MainThreadToken: Zero-sized token that can only exist on the main thread.MainThreadData: Wrapper for data that can move between threads but that should
only be accessed on the main thread.run_sync_on_main_thread(): Run a callback on the main thread, synchronously.run_async_on_main_thread(): Run a callback on the main thread, asynchronously.| Feature | Description |
|---|---|
alloc |
Enable features that require allocation (enabled by default) |
std |
Enable features that require the standard library (enabled by default) |
nightly |
Enable the ? operator to convert Result::Err and Option::None to AppResult*::Failure |
use-parking-lot-v0-12 |
Support parking_lot 0.12 locks in app state accessors |
0.5.4:
0.5.3:
run_async_on_main_thread if the size of
the callback is zero, because that's the only way to guarantee we won't copy
uninit bytes, which would be unsound0.5.2:
run_async_on_main_thread0.5.1:
run_async_on_main_threadrun_async_on_main_thread unless it's necessary0.5.0:
run_{sync,async}_on_main_thread and MainThreadData::get[_mut]_on_main_threadCopy for MainThreadTokenFromResidual for AppResult* on nightlySee ChangeLog.md for older changes