pub trait Cacheable: Default {
// Required methods
fn commit(&mut self, dh: &DisplayHandle) -> Self;
fn merge_into(self, into: &mut Self, dh: &DisplayHandle);
}
wayland_frontend
only.Expand description
Trait representing a value that can be used in double-buffered storage
The type needs to implement the Default
trait, which will be used
to initialize. You further need to provide two methods:
Cacheable::commit
and Cacheable::merge_into
.
Double-buffered state works by having a “pending” instance of your type,
into which new values provided by the client are inserted. When the client
sends wl_surface.commit
, the Cacheable::commit
method will be
invoked on your value. This method is expected to produce a new instance of
your type, that will be stored in the cache, and eventually merged into the
current state.
In most cases, this method will simply produce a copy of the pending state, but you might need additional logic in some cases, such as for handling non-cloneable resources (which thus need to be moved into the produce value).
Then at some point the Cacheable::merge_into
method of your type will be
invoked. In this method, self
acts as the update that should be merged into
the current state provided as argument. In simple cases, the action would just
be to copy self
into the current state, but more complex cases require
additional logic.
Required Methods§
Sourcefn commit(&mut self, dh: &DisplayHandle) -> Self
fn commit(&mut self, dh: &DisplayHandle) -> Self
Produce a new state to be cached from the pending state
Sourcefn merge_into(self, into: &mut Self, dh: &DisplayHandle)
fn merge_into(self, into: &mut Self, dh: &DisplayHandle)
Merge a state update into the current state
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl Cacheable for AlphaModifierSurfaceCachedState
impl Cacheable for ContentTypeSurfaceCachedState
impl Cacheable for DrmSyncobjCachedState
backend_drm
only.impl Cacheable for FifoBarrierCachedState
impl Cacheable for FifoCachedState
impl Cacheable for PresentationFeedbackCachedState
impl Cacheable for LayerSurfaceCachedState
impl Cacheable for SurfaceCachedState
impl Cacheable for ViewportCachedState
impl Cacheable for ToplevelIconCachedState
impl Cacheable for XWaylandShellCachedState
xwayland
only.