pub struct Client { /* private fields */ }
Expand description
A struct representing a Wayland client connected to your compositor.
Implementations§
source§impl Client
impl Client
sourcepub fn get_data<Data: ClientData + 'static>(&self) -> Option<&Data>
pub fn get_data<Data: ClientData + 'static>(&self) -> Option<&Data>
Access the data associated to this client
Returns None
if the provided Data
type parameter is not the correct one.
sourcepub fn get_credentials(
&self,
handle: &DisplayHandle,
) -> Result<Credentials, InvalidId>
pub fn get_credentials( &self, handle: &DisplayHandle, ) -> Result<Credentials, InvalidId>
Access the pid/uid/gid of this client
Note: You should be careful if you plan tu use this for security purposes, as it is possible for programs to spoof this kind of information.
For a discussion about the subject of securely identifying clients, see https://gitlab.freedesktop.org/wayland/weston/-/issues/206
sourcepub fn create_resource<I: Resource + 'static, U: Send + Sync + 'static, D: Dispatch<I, U> + 'static>(
&self,
handle: &DisplayHandle,
version: u32,
user_data: U,
) -> Result<I, InvalidId>
pub fn create_resource<I: Resource + 'static, U: Send + Sync + 'static, D: Dispatch<I, U> + 'static>( &self, handle: &DisplayHandle, version: u32, user_data: U, ) -> Result<I, InvalidId>
Create a new Wayland object in the protocol state of this client
The newly created resource should be immediately sent to the client through an associated event with
a new_id
argument. Not doing so risks corrupting the protocol state and causing protocol errors at
a later time.
sourcepub fn create_resource_from_objdata<I: Resource + 'static, D: 'static>(
&self,
handle: &DisplayHandle,
version: u32,
obj_data: Arc<dyn ObjectData<D>>,
) -> Result<I, InvalidId>
pub fn create_resource_from_objdata<I: Resource + 'static, D: 'static>( &self, handle: &DisplayHandle, version: u32, obj_data: Arc<dyn ObjectData<D>>, ) -> Result<I, InvalidId>
Create a new Wayland object in the protocol state of this client, from an ObjectData
This is a lower-level method than create_resource()
, in case you need to
bypass the Dispatch
machinery.
The newly created resource should be immediately sent to the client through an associated event with
a new_id
argument. Not doing so risks corrupting the protocol state and causing protocol errors at
a later time.
sourcepub fn object_from_protocol_id<I: Resource + 'static>(
&self,
handle: &DisplayHandle,
protocol_id: u32,
) -> Result<I, InvalidId>
pub fn object_from_protocol_id<I: Resource + 'static>( &self, handle: &DisplayHandle, protocol_id: u32, ) -> Result<I, InvalidId>
Attempt to retrieve an object from this client’s protocol state from its protocol id
Will fail if either the provided protocol id does not correspond to any object, or if the
corresponding object is not of the interface I
.
sourcepub fn kill(&self, handle: &DisplayHandle, error: ProtocolError)
pub fn kill(&self, handle: &DisplayHandle, error: ProtocolError)
Kill this client by triggering a protocol error
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.