Skip to content

Document producer/consumer relationship#202

Open
madsmtm wants to merge 1 commit intomasterfrom
madsmtm/docs-consumer-producer
Open

Document producer/consumer relationship#202
madsmtm wants to merge 1 commit intomasterfrom
madsmtm/docs-consumer-producer

Conversation

@madsmtm
Copy link
Member

@madsmtm madsmtm commented Feb 28, 2026

Part of #193.

@madsmtm madsmtm added the documentation Improvements or additions to documentation label Feb 28, 2026
@madsmtm madsmtm force-pushed the madsmtm/docs-consumer-producer branch from 9d940c6 to 0afced4 Compare February 28, 2026 21:14
Comment on lines +43 to +46
//! Examples of consumer crates include [`softbuffer`](https://docs.rs/softbuffer/),
//! [`glutin`](https://docs.rs/glutin/) and [`wgpu`](https://docs.rs/wgpu/), consider these
//! "reference implementations" of consumer crates. Other examples include
//! [`ash-window`](https://docs.rs/ash-window/) and [`pixels`](https://docs.rs/pixels/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: what here makes the difference between the crates before "consider these reference implementations" and after? Maybe the is useful to communicate to the user?

Copy link
Member Author

@madsmtm madsmtm Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my mind, it's that I will actively go and fix the rwh integration for these crates. But yeah, we could make this clearer, and maybe it makes sense to remove wgpu from the list (since we don't actually control that crate).

Copy link
Member

@MarijnS95 MarijnS95 Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do PR to wgpu from time to time (specifically WRT windowing / surface handles), but it's so humongous (and has an insane amount of insultingly low-quality PR contributions, I feel sorry for the maintainers) that it's almost impossible to get back into it every time, for example once one of the maintainers finally comes around to re-review my PR (because of otherwise having to deal with noise...).


ash-window is my area fwiw, but it can't do much if anything for lifetimes after handing out a cheaply-copyable VkSurfaceKHR handle; unless we re-wrap it in a smarter type that sparingly hands it out.

Comment on lines +48 to +54
//! Another type of producer is those that use the window handle to access either the platform
//! widget/view or the actual window, and performs some operation that requires that. Examples of
//! this include [`rfd`](https://docs.rs/rfd/), [`wry`](https://docs.rs/wry/),
//! [`muda`](https://docs.rs/muda/), [`window_clipboard`](https://docs.rs/window_clipboard/),
//! [`ashpd`](https://docs.rs/ashpd/), [`window-vibrancy`](https://docs.rs/window-vibrancy/),
//! [`window-shadows`](https://docs.rs/window-shadows/) and
//! [`native-dialog`](https://docs.rs/native-dialog/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are consumers, right? They take a RWH to interface with the OS for non-graphics like clipboard access, popup dialogs and whatnot (perhaps mention what these crates do in brief, as it's not always clear from the crate name).

Suggested change
//! Another type of producer is those that use the window handle to access either the platform
//! widget/view or the actual window, and performs some operation that requires that. Examples of
//! this include [`rfd`](https://docs.rs/rfd/), [`wry`](https://docs.rs/wry/),
//! [`muda`](https://docs.rs/muda/), [`window_clipboard`](https://docs.rs/window_clipboard/),
//! [`ashpd`](https://docs.rs/ashpd/), [`window-vibrancy`](https://docs.rs/window-vibrancy/),
//! [`window-shadows`](https://docs.rs/window-shadows/) and
//! [`native-dialog`](https://docs.rs/native-dialog/).
//! Another type of consumer is those that use the window handle to access either the platform
//! widget/view or the actual window, and performs some operation that requires that. Examples of
//! this include [`rfd`](https://docs.rs/rfd/), [`wry`](https://docs.rs/wry/),
//! [`muda`](https://docs.rs/muda/), [`window_clipboard`](https://docs.rs/window_clipboard/),
//! [`ashpd`](https://docs.rs/ashpd/), [`window-vibrancy`](https://docs.rs/window-vibrancy/),
//! [`window-shadows`](https://docs.rs/window-shadows/) and
//! [`native-dialog`](https://docs.rs/native-dialog/).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ofc., I wrote wrong

#![deny(unsafe_op_in_unsafe_fn)]

//! Interoperability library for Rust Windowing applications.
//! # Interoperability helper between graphics crates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the new title is actually less accurate than the previous one.
What we offer here is interoperability between windowing and graphic libraries.

Potentially we also help multiple graphics libraries communicate a window between each other, but that's not really the main use case.

Suggested change
//! # Interoperability helper between graphics crates
//! # Interoperability Types For Window Handles

I believe in general we should not frame everything around graphics and surfaces. As you already point out somewhere else in the documentation, there are also consumers that just work with the window directly.

//! managing windows; instead, it provides a common interface that window creation libraries (e.g.
//! Winit, SDL) can use to easily talk with graphics libraries (e.g. gfx-hal).
//! This crate is intended as an interoperability crate, that allows "producer" crates to create a
//! handle to a window surface, and for this handle to be passed onwards to "consumer" crates for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we discussed offering that. But right now we are still providing window handles, not surface handles.

Comment on lines +27 to +28
//! types to allow more easily using them with consumer crates. Examples of this include `x11rb`,
//! `ndk`, `orbclient` and `wayland-backend`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! types to allow more easily using them with consumer crates. Examples of this include `x11rb`,
//! `ndk`, `orbclient` and `wayland-backend`.
//! types to allow more easily using them with consumer crates. Examples of this include [`x11rb`](https://docs.rs/x11rb),
//! [`ndk`](https://docs.rs/ndk), [`orbclient`](https://docs.rs/orbclient) and [`wayland-backend`](https://docs.rs/wayland-backend).

//!
//! ## Consumers
//!
//! Consumer crates expose some sort of "surface" type that renders into a provided window handle.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that in general we should reframe this as just an example of what a consumer crate might do. You already point out further down that there are consumers who just work with the window directly.

Suggested change
//! Consumer crates expose some sort of "surface" type that renders into a provided window handle.
//! Consumer crates typically expose some sort of "surface" type that renders into a provided window handle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Development

Successfully merging this pull request may close these issues.

3 participants