Skip to content

Commit 0afced4

Browse files
committed
Document producer/consumer relationship
1 parent 74af1fe commit 0afced4

3 files changed

Lines changed: 56 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "raw-window-handle"
33
version = "0.6.2"
44
authors = ["Osspial <osspial@gmail.com>"]
55
edition = "2021"
6-
description = "Interoperability library for Rust Windowing applications."
6+
description = "Interoperability helper between graphics crates"
77
license = "MIT OR Apache-2.0 OR Zlib"
88
repository = "https://github.com/rust-windowing/raw-window-handle"
99
keywords = ["windowing"]

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
[![Docs](https://docs.rs/raw-window-handle/badge.svg)](https://docs.rs/raw-window-handle)
55
[![CI Status](https://github.com/rust-windowing/raw-window-handle/workflows/CI/badge.svg)](https://github.com/rust-windowing/raw-window-handle/actions)
66

7-
This library provides standard types for accessing a window's platform-specific
8-
raw window handle and display's platform-specific raw display handle. This does
9-
not provide any utilities for creating and managing windows; instead, it
10-
provides a common interface that window creation libraries (e.g. Winit, SDL)
11-
can use to easily talk with graphics libraries (e.g. gfx-hal).
7+
This crate is intended as an interoperability crate, that allows "producer"
8+
crates to create a handle to a window surface, and for this handle to be
9+
passed onwards to "consumer" crates for rendering to that surface.
10+
11+
This crate does not by itself provide any utilities for creating and managing
12+
windows, nor for rendering into them; use Winit or SDL for the former, and
13+
Softbuffer, Glutin or Wgpu for the latter.
1214

1315
## MSRV Policy
1416

src/lib.rs

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,55 @@
33
#![allow(clippy::new_without_default)]
44
#![deny(unsafe_op_in_unsafe_fn)]
55

6-
//! Interoperability library for Rust Windowing applications.
6+
//! # Interoperability helper between graphics crates
77
//!
8-
//! This library provides standard types for accessing a window's platform-specific raw window
9-
//! handle and platforms display handle. This does not provide any utilities for creating and
10-
//! managing windows; instead, it provides a common interface that window creation libraries (e.g.
11-
//! Winit, SDL) can use to easily talk with graphics libraries (e.g. gfx-hal).
8+
//! This crate is intended as an interoperability crate, that allows "producer" crates to create a
9+
//! handle to a window surface, and for this handle to be passed onwards to "consumer" crates for
10+
//! rendering to that surface.
11+
//!
12+
//! This crate does not by itself provide any utilities for creating and managing windows, nor for
13+
//! rendering into them.
14+
//!
15+
//! ## Producers
16+
//!
17+
//! Producer crates provide some sort of "window" type that implements [`HasWindowHandle`], and
18+
//! ensures that the [`WindowHandle`] returned from that is alive for as long as the window is. The
19+
//! primary example of this is [`winit`](https://docs.rs/winit/), consider that the "reference
20+
//! implementation" of a producer crate.
21+
//!
22+
//! Other cross-platform producer crates include [`sdl3`](https://docs.rs/sdl3/),
23+
//! [`sdl2`](https://docs.rs/sdl2/), [`minifb`](https://docs.rs/minifb/),
24+
//! [`glfw`](https://docs.rs/glfw/) and [`fltk`]](https://docs.rs/fltk/).
25+
//!
26+
//! Some platform-specific toolkits might also decide to implement `HasWindowHandle` for their
27+
//! types to allow more easily using them with consumer crates. Examples of this include `x11rb`,
28+
//! `ndk`, `orbclient` and `wayland-backend`.
29+
//!
30+
//! ## Consumers
31+
//!
32+
//! Consumer crates expose some sort of "surface" type that renders into a provided window handle.
33+
//!
34+
//! In general, consumer crates must either be generic over the handle type, or contain a lifetime
35+
//! to it, because on some platforms (Wayland, GBM, maybe more?) that is the only way to ensure that
36+
//! the handle is not deallocated while in use by the surface.
37+
//! ```
38+
//! struct Surface<W: HasWindowHandle> {
39+
//! handle: W,
40+
//! }
41+
//! ```
42+
//!
43+
//! Examples of consumer crates include [`softbuffer`](https://docs.rs/softbuffer/),
44+
//! [`glutin`](https://docs.rs/glutin/) and [`wgpu`](https://docs.rs/wgpu/), consider these
45+
//! "reference implementations" of consumer crates. Other examples include
46+
//! [`ash-window`](https://docs.rs/ash-window/) and [`pixels`](https://docs.rs/pixels/).
47+
//!
48+
//! Another type of producer is those that use the window handle to access either the platform
49+
//! widget/view or the actual window, and performs some operation that requires that. Examples of
50+
//! this include [`rfd`](https://docs.rs/rfd/), [`wry`](https://docs.rs/wry/),
51+
//! [`muda`](https://docs.rs/muda/), [`window_clipboard`](https://docs.rs/window_clipboard/),
52+
//! [`ashpd`](https://docs.rs/ashpd/), [`window-vibrancy`](https://docs.rs/window-vibrancy/),
53+
//! [`window-shadows`](https://docs.rs/window-shadows/) and
54+
//! [`native-dialog`](https://docs.rs/native-dialog/).
1255
//!
1356
//! ## Safety guarantees
1457
//!

0 commit comments

Comments
 (0)