[−][src]Struct wayland_server::NewResource
A newly-created resource that needs implementation
Whenever a new wayland object is created, you will
receive it as a NewResource
. You then have to provide an
implementation for it, in order to process the incoming
events it may receive. Once this done you will be able
to use it as a regular Rust object.
Implementations are structs implementing the appropriate
variant of the Implementation
trait. They can also be
closures.
Methods
impl<I: Interface + 'static> NewResource<I>
[src]
pub fn implement<T, Dest, UD>(
self,
handler: T,
destructor: Option<Dest>,
user_data: UD
) -> I where
T: 'static,
Dest: FnMut(I) + 'static,
UD: 'static,
I: HandledBy<T> + From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
[src]
self,
handler: T,
destructor: Option<Dest>,
user_data: UD
) -> I where
T: 'static,
Dest: FnMut(I) + 'static,
UD: 'static,
I: HandledBy<T> + From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
Implement this resource using a handler, destructor and user data.
The handler is a struct implementing the RequestHandler
trait for the corresponding
interface.
This must be called from the thread hosting the wayland event loop, otherwise it will panic.
If you want the user data to be accessed from other threads,
see implement_user_data_threadsafe
.
pub fn implement_closure<F, Dest, UD>(
self,
implementation: F,
destructor: Option<Dest>,
user_data: UD
) -> I where
F: FnMut(I::Request, I) + 'static,
Dest: FnMut(I) + 'static,
UD: 'static,
I: From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
[src]
self,
implementation: F,
destructor: Option<Dest>,
user_data: UD
) -> I where
F: FnMut(I::Request, I) + 'static,
Dest: FnMut(I) + 'static,
UD: 'static,
I: From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
Implement this resource using given function, destructor, and user data.
This must be called from the thread hosting the wayland event loop, otherwise it will panic.
If you want the user data to be accessed from other threads,
see implement_closure_user_data_threadsafe
.
pub fn implement_dummy(self) -> I where
I: From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
[src]
I: From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
Implement this resource using a dummy handler which does nothing.
pub fn implement_threadsafe<T, Dest, UD>(
self,
handler: T,
destructor: Option<Dest>,
user_data: UD
) -> I where
T: Send + 'static,
Dest: FnMut(I) + Send + 'static,
UD: Send + Sync + 'static,
I: HandledBy<T> + From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
[src]
self,
handler: T,
destructor: Option<Dest>,
user_data: UD
) -> I where
T: Send + 'static,
Dest: FnMut(I) + Send + 'static,
UD: Send + Sync + 'static,
I: HandledBy<T> + From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
Implement this resource using a handler, destructor and user data.
The handler is a struct implementing the RequestHandler
trait for the corresponding
interface.
This method allows you to implement from any thread with the constraint that the implementation and user-data must be threadsafe.
pub fn implement_closure_threadsafe<F, Dest, UD>(
self,
implementation: F,
destructor: Option<Dest>,
user_data: UD
) -> I where
F: FnMut(I::Request, I) + Send + 'static,
Dest: FnMut(I) + Send + 'static,
UD: Send + Sync + 'static,
I: From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
[src]
self,
implementation: F,
destructor: Option<Dest>,
user_data: UD
) -> I where
F: FnMut(I::Request, I) + Send + 'static,
Dest: FnMut(I) + Send + 'static,
UD: Send + Sync + 'static,
I: From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
Implement this resource using given function, destructor, and user data.
This method allows you to implement from any thread with the constraint that the implementation and user-data must be threadsafe.
pub fn implement_user_data_threadsafe<T, Dest, UD>(
self,
handler: T,
destructor: Option<Dest>,
user_data: UD
) -> I where
T: 'static,
Dest: FnMut(I) + 'static,
UD: Send + Sync + 'static,
I: HandledBy<T> + From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
[src]
self,
handler: T,
destructor: Option<Dest>,
user_data: UD
) -> I where
T: 'static,
Dest: FnMut(I) + 'static,
UD: Send + Sync + 'static,
I: HandledBy<T> + From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
Implement this resource using a handler, destructor and user data.
The handler is a struct implementing the RequestHandler
trait for the corresponding
interface.
This must be called from the thread hosting the wayland event loop, otherwise it will panic. However the user data can be accessed from other threads.
pub fn implement_closure_user_data_threadsafe<F, Dest, UD>(
self,
implementation: F,
destructor: Option<Dest>,
user_data: UD
) -> I where
F: FnMut(I::Request, I) + 'static,
Dest: FnMut(I) + 'static,
UD: Send + Sync + 'static,
I: From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
[src]
self,
implementation: F,
destructor: Option<Dest>,
user_data: UD
) -> I where
F: FnMut(I::Request, I) + 'static,
Dest: FnMut(I) + 'static,
UD: Send + Sync + 'static,
I: From<Resource<I>>,
I::Request: MessageGroup<Map = ResourceMap>,
Implement this resource using given function, destructor, and user data.
This must be called from the thread hosting the wayland event loop, otherwise it will panic. However the user data can be accessed from other threads.
impl<I: Interface> NewResource<I>
[src]
pub fn c_ptr(&self) -> *mut wl_resource
[src]
Get a raw pointer to the underlying wayland object
Retrieve a pointer to the object from the libwayland-server.so
library.
You will mostly need it to interface with C libraries needing access
to wayland objects.
Use this if you need to pass an unimplemented object to the C library you are interfacing with.
NOTE: This method will panic if called while the native_lib
feature is not
activated
pub unsafe fn from_c_ptr(_ptr: *mut wl_resource) -> Self
[src]
Create a NewResource
instance from a C pointer.
By doing so, you assert that this wayland object was newly created and can be safely implemented. As implementing it will overwrite any previously associated data or implementation, this can cause weird errors akin to memory corruption if it was not the case.
NOTE: This method will panic if called while the native_lib
feature is not
activated
Auto Trait Implementations
impl<I> Unpin for NewResource<I>
impl<I> !Sync for NewResource<I>
impl<I> !Send for NewResource<I>
impl<I> UnwindSafe for NewResource<I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
impl<I> RefUnwindSafe for NewResource<I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Downcast for T where
T: Any,
[src]
T: Any,