luminvent_raw_window_handle/web.rs
1/// Raw window handle for the Web.
2///
3/// ## Construction
4/// ```
5/// # use raw_window_handle::WebHandle;
6/// let mut handle = WebHandle::empty();
7/// /* set fields */
8/// ```
9#[non_exhaustive]
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
11pub struct WebHandle {
12 /// An ID value inserted into the [data attributes] of the canvas element as '`raw-handle`'.
13 ///
14 /// When accessing from JS, the attribute will automatically be called `rawHandle`.
15 ///
16 /// Each canvas created by the windowing system should be assigned their own unique ID.
17 /// 0 should be reserved for invalid / null IDs.
18 ///
19 /// [data attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*
20 pub id: uuid::Uuid,
21}
22
23impl WebHandle {
24 pub fn empty() -> Self {
25 Self { id: uuid::Uuid::new_v4() }
26 }
27}