smithay/wayland/buffer/
mod.rs

1//! Buffer management traits.
2//!
3//! This module provides the [`BufferHandler`] trait to notify compositors that a
4//! [`WlBuffer`](wayland_server::protocol::wl_buffer::WlBuffer) managed by
5//! Smithay has been destroyed.
6
7use wayland_server::protocol::wl_buffer;
8
9/// Handler trait for associating data with a [`WlBuffer`](wayland_server::protocol::wl_buffer::WlBuffer).
10///
11/// This trait primarily allows compositors to be told when a buffer is destroyed.
12///
13/// # For buffer abstractions
14///
15/// Buffer abstractions (such as [`shm`](crate::wayland::shm)) should require this trait in their
16/// [`delegate_dispatch`](wayland_server::delegate_dispatch) implementations to notify the compositor when a
17/// buffer is destroyed.
18pub trait BufferHandler {
19    /// Called when the client has destroyed the buffer.
20    ///
21    /// At this point the buffer is no longer usable by Smithay.
22    fn buffer_destroyed(&mut self, buffer: &wl_buffer::WlBuffer);
23}