Trait wayland_server::Resource
[−]
[src]
pub trait Resource {
fn ptr(&self) -> *mut wl_resource;
unsafe fn from_ptr_new(_: *mut wl_resource) -> Self;
unsafe fn from_ptr_initialized(_: *mut wl_resource) -> Self;
fn interface_ptr() -> *const wl_interface;
fn interface_name() -> &'static str;
fn supported_version() -> u32;
fn version(&self) -> i32;
fn is_alive(&self) -> bool;
fn equals(&self, _: &Self) -> bool;
fn set_user_data(&self, ptr: *mut ());
fn get_user_data(&self) -> *mut ();
fn post_error(&self, error_code: u32, msg: String) { ... }
}Common routines for wayland resource objects.
All wayland objects automatically implement this trait as generated by the scanner.
It is mostly used for internal use by the library, and you should only need these methods for interfacing with C library working on wayland objects.
Required Methods
fn ptr(&self) -> *mut wl_resource
Pointer to the underlying wayland proxy object
unsafe fn from_ptr_new(_: *mut wl_resource) -> Self
Create an instance from a wayland pointer
The pointer must refer to a valid wayland resource of the appropriate interface, but that have not yet been seen by the library.
The library will take control of the object (notably overwrite its user_data).
unsafe fn from_ptr_initialized(_: *mut wl_resource) -> Self
Create an instance from a wayland pointer
The pointer must refer to a valid wayland resource of the appropriate interface, and have already been initialized by the library (it'll assume this proxy user_data contains a certain kind of data).
fn interface_ptr() -> *const wl_interface
Pointer to the interface representation
fn interface_name() -> &'static str
Internal wayland name of this interface
fn supported_version() -> u32
Max version of this interface supported
fn version(&self) -> i32
Current version of the interface this resource is instanciated with
fn is_alive(&self) -> bool
Check if the resource behind this handle is actually still alive
fn equals(&self, _: &Self) -> bool
Check of two handles are actually the same wayland object
Returns false if any of the objects has already been destroyed
fn set_user_data(&self, ptr: *mut ())
Set a pointer associated as user data on this resource
All handles to the same wayland object share the same user data pointer.
The get/set operations are atomic, no more guarantee is given. If you need to synchronise access to this data, it is your responsibility to add a Mutex or any other similar mechanism.
fn get_user_data(&self) -> *mut ()
Get the pointer associated as user data on this resource
All handles to the same wayland object share the same user data pointer.
See set_user_data for synchronisation guarantee.
Provided Methods
fn post_error(&self, error_code: u32, msg: String)
Posts a protocol error to this resource
The error code can be obtained from the various Error enums of the protocols.
An error is fatal to the client that caused it.
Implementors
impl Resource for WlCallbackimpl Resource for WlCompositorimpl Resource for WlShmPoolimpl Resource for WlShmimpl Resource for WlBufferimpl Resource for WlDataOfferimpl Resource for WlDataSourceimpl Resource for WlDataDeviceimpl Resource for WlDataDeviceManagerimpl Resource for WlShellimpl Resource for WlShellSurfaceimpl Resource for WlSurfaceimpl Resource for WlSeatimpl Resource for WlPointerimpl Resource for WlKeyboardimpl Resource for WlTouchimpl Resource for WlOutputimpl Resource for WlRegionimpl Resource for WlSubcompositorimpl Resource for WlSubsurface