[][src]Struct wayland_client::NewProxy

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

A newly-created proxy that needs implementation

Whenever a new wayland object is created, you will receive it as a NewProxy. 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.

Implementations

impl<I: Interface + 'static> NewProxy<I>[src]

pub fn implement<T, UD>(self, handler: T, user_data: UD) -> I where
    T: 'static,
    UD: 'static,
    I: HandledBy<T> + From<Proxy<I>>,
    I::Event: MessageGroup<Map = ProxyMap>, 
[src]

Implement this proxy using the given handler and implementation data.

The handler must be a struct implementing the EventHandler trait of the I interface.

This must be called from the same thread as the one owning the event queue this new proxy is attached to and will panic otherwise. A proxy by default inherits the event queue of its parent object.

If you don't want an object to inherits its parent queue, see Proxy::make_wrapper.

If you want the user data to be accessed from other threads, see implement_user_data_threadsafe.

pub fn implement_closure<F, UD>(self, implementation: F, user_data: UD) -> I where
    F: FnMut(I::Event, I) + 'static,
    UD: 'static,
    I: From<Proxy<I>>,
    I::Event: MessageGroup<Map = ProxyMap>, 
[src]

Implement this proxy using the given implementation closure and implementation data.

This must be called from the same thread as the one owning the event queue this new proxy is attached to and will panic otherwise. A proxy by default inherits the event queue of its parent object.

If you don't want an object to inherits its parent queue, see Proxy::make_wrapper.

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<Proxy<I>>,
    I::Event: MessageGroup<Map = ProxyMap>, 
[src]

Implement this proxy using a dummy handler which does nothing.

pub fn implement_threadsafe<T, UD>(self, handler: T, user_data: UD) -> I where
    T: Send + 'static,
    UD: Send + Sync + 'static,
    I: HandledBy<T> + From<Proxy<I>>,
    I::Event: MessageGroup<Map = ProxyMap>, 
[src]

Implement this proxy using the given handler and implementation data.

The handler must be a struct implementing the EventHandler trait of the I interface.

This function allows you to implement a proxy from an other thread than the one where its event queue is attach, but the implementation thus must be Send.

pub fn implement_closure_threadsafe<F, UD>(
    self,
    implementation: F,
    user_data: UD
) -> I where
    F: FnMut(I::Event, I) + Send + 'static,
    UD: Send + Sync + 'static,
    I: From<Proxy<I>>,
    I::Event: MessageGroup<Map = ProxyMap>, 
[src]

Implement this proxy using given closure and implementation data from any thread.

This function allows you to implement a proxy from an other thread than the one where its event queue is attach, but the implementation thus must be Send.

pub fn implement_user_data_threadsafe<T, UD>(
    self,
    handler: T,
    user_data: UD
) -> I where
    T: 'static,
    UD: Send + Sync + 'static,
    I: HandledBy<T> + From<Proxy<I>>,
    I::Event: MessageGroup<Map = ProxyMap>, 
[src]

Implement this proxy using the given handler and implementation data.

This must be called from the same thread as the one owning the event queue this new proxy is attached to and will panic otherwise. However the user data may be accessed from other threads.

pub fn implement_closure_user_data_threadsafe<F, UD>(
    self,
    implementation: F,
    user_data: UD
) -> I where
    F: FnMut(I::Event, I) + 'static,
    UD: Send + Sync + 'static,
    I: From<Proxy<I>>,
    I::Event: MessageGroup<Map = ProxyMap>, 
[src]

Implement this proxy using the given closure and implementation data.

This must be called from the same thread as the one owning the event queue this new proxy is attached to and will panic otherwise. However the user data may be accessed from other threads.

impl<I: Interface + 'static> NewProxy<I>[src]

pub fn c_ptr(&self) -> *mut wl_proxy[src]

Get a raw pointer to the underlying wayland object

Retrieve a pointer to the object from the libwayland-client.so library. You will mostly need it to interface with C libraries needing access to wayland objects (to initialize an opengl context for example).

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_proxy) -> Self[src]

Create a NewProxy 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> RefUnwindSafe for NewProxy<I> where
    I: RefUnwindSafe

impl<I> !Send for NewProxy<I>

impl<I> !Sync for NewProxy<I>

impl<I> Unpin for NewProxy<I>

impl<I> UnwindSafe for NewProxy<I> where
    I: RefUnwindSafe

Blanket Implementations

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

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.