Function runa_core::client::dispatch_to

source ·
pub fn dispatch_to<'a, Ctx, R>(
    ctx: &'a mut Ctx,
    reader: Pin<&'a mut R>
) -> Dispatch<'a, Ctx, R>where
    R: AsyncBufReadWithFd,
    Ctx: Client,
    Ctx::Object: for<'b> Object<Ctx, Request<'b> = (&'b [u8], &'b [RawFd])>,
Expand description

Reference implementation of the traits::Client::dispatch method.

This function reads a message from reader, looks up the corresponding object, and then calls the object’s dispatch method to handle the message. It then checks if the dispatch method returned an error, and if so, sends the error to the client. The returned future resolves to a boolean, which indicates whether the client should be disconnected.

You can simply call this function as the implementation of your own dispatch method.

Notice there is a type bound requiring Ctx::Object to accept a (&[u8], &[RawFd]) as its request type. This would be the case if you use #[derive(Object) to generate you object type. If not, you are supposed to deserialize a wayland message from a (&[u8], &[RawFd]) tuple yourself and then dispatch the deserialized message properly.