[][src]Struct wayland_server::NewResource

pub struct NewResource<I: Interface> { /* fields omitted */ }

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]

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.

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]

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.

pub fn implement_dummy(self) -> I where
    I: From<Resource<I>>,
    I::Request: MessageGroup<Map = ResourceMap>, 
[src]

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]

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]

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.

Auto Trait Implementations

impl<I> !Send for NewResource<I>

impl<I> !Sync for NewResource<I>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]