File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ #### Additions
6+
7+ - Add ` Weak::is_alive ` allowing to check if a resource is still alive.
8+
59## 0.31.1 -- 2024-01-29
610
711- Dropped ` nix ` dependency in favor of ` rustix `
Original file line number Diff line number Diff line change @@ -293,6 +293,19 @@ impl<I: Resource> Weak<I> {
293293 I :: from_id ( & d_handle, self . id . clone ( ) )
294294 }
295295
296+ /// Check if this resource is still alive
297+ ///
298+ /// This will return `false` if either:
299+ /// - the object represented by this handle has already been destroyed at the protocol level
300+ /// - the Wayland connection has already been closed
301+ #[ inline]
302+ pub fn is_alive ( & self ) -> bool {
303+ let Some ( handle) = self . handle . upgrade ( ) else {
304+ return false ;
305+ } ;
306+ handle. object_info ( self . id . clone ( ) ) . is_ok ( )
307+ }
308+
296309 /// The underlying [`ObjectId`]
297310 pub fn id ( & self ) -> ObjectId {
298311 self . id . clone ( )
You can’t perform that action at this time.
0 commit comments