wayland_server

Trait Resource

Source
pub trait Resource:
    Clone
    + Debug
    + Sized {
    type Event<'a>;
    type Request;

Show 14 methods // Required methods fn interface() -> &'static Interface; fn id(&self) -> ObjectId; fn version(&self) -> u32; fn data<U: 'static>(&self) -> Option<&U>; fn object_data(&self) -> Option<&Arc<dyn Any + Send + Sync>>; fn handle(&self) -> &WeakHandle; fn from_id(dh: &DisplayHandle, id: ObjectId) -> Result<Self, InvalidId>; fn send_event(&self, evt: Self::Event<'_>) -> Result<(), InvalidId>; fn parse_request( dh: &DisplayHandle, msg: Message<ObjectId, OwnedFd>, ) -> Result<(Self, Self::Request), DispatchError>; fn write_event<'a>( &self, dh: &DisplayHandle, req: Self::Event<'a>, ) -> Result<Message<ObjectId, BorrowedFd<'a>>, InvalidId>; // Provided methods fn client(&self) -> Option<Client> { ... } fn is_alive(&self) -> bool { ... } fn post_error(&self, code: impl Into<u32>, error: impl Into<String>) { ... } fn downgrade(&self) -> Weak<Self> { ... }
}
Expand description

Trait representing a Wayland interface

Required Associated Types§

Source

type Event<'a>

The event enum for this interface

Source

type Request

The request enum for this interface

Required Methods§

Source

fn interface() -> &'static Interface

The interface description

Source

fn id(&self) -> ObjectId

The ID of this object

Source

fn version(&self) -> u32

The version of this object

Source

fn data<U: 'static>(&self) -> Option<&U>

Access the user-data associated with this object

Source

fn object_data(&self) -> Option<&Arc<dyn Any + Send + Sync>>

Access the raw data associated with this object.

It is given to you as a dyn Any, and you are responsible for downcasting it.

For objects created using the scanner-generated methods, this will be an instance of the ResourceData type.

Source

fn handle(&self) -> &WeakHandle

Access the backend handle associated with this object

Source

fn from_id(dh: &DisplayHandle, id: ObjectId) -> Result<Self, InvalidId>

Create an object resource from its ID

Returns an error this the provided object ID does not correspond to the Self interface.

Note: This method is mostly meant as an implementation detail to be used by code generated by wayland-scanner.

Source

fn send_event(&self, evt: Self::Event<'_>) -> Result<(), InvalidId>

Send an event to this object

Source

fn parse_request( dh: &DisplayHandle, msg: Message<ObjectId, OwnedFd>, ) -> Result<(Self, Self::Request), DispatchError>

Parse a event for this object

Note: This method is mostly meant as an implementation detail to be used by code generated by wayland-scanner.

Source

fn write_event<'a>( &self, dh: &DisplayHandle, req: Self::Event<'a>, ) -> Result<Message<ObjectId, BorrowedFd<'a>>, InvalidId>

Serialize an event for this object

Note: This method is mostly meant as an implementation detail to be used by code generated by wayland-scanner.

Provided Methods§

Source

fn client(&self) -> Option<Client>

The client owning this object

Returns None if the object is no longer alive.

Source

fn is_alive(&self) -> bool

Checks if the Wayland object associated with this proxy is still alive

Source

fn post_error(&self, code: impl Into<u32>, error: impl Into<String>)

Trigger a protocol error on this object

The code is intended to be from the Error enum declared alongside that object interface.

A protocol error is fatal to the Wayland connection, and the client will be disconnected.

Source

fn downgrade(&self) -> Weak<Self>

Creates a weak handle to this object

This weak handle will not keep the user-data associated with the object alive, and can be converted back to a full resource using Weak::upgrade().

This can be of use if you need to store resources in the used data of other objects and want to be sure to avoid reference cycles that would cause memory leaks.

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§

Source§

impl Resource for WlBuffer

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlCallback

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlCompositor

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlDataDevice

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlDataDeviceManager

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlDataOffer

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlDataSource

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlKeyboard

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlOutput

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlPointer

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlRegion

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlSeat

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlShell

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlShellSurface

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlShm

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlShmPool

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlSubcompositor

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlSubsurface

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlSurface

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>

Source§

impl Resource for WlTouch

Source§

type Request = Request

Source§

type Event<'event> = Event<'event>