Struct wayland_bridge::client::Client
source · pub struct Client {
pub input_dispatcher: InputDispatcher,
pub xdg_surfaces: Vec<ObjectRef<XdgSurface>>,
/* private fields */
}
Expand description
The state of a single client connection. Each client connection will have have its own zircon channel and its own set of protocol objects. The |Display| is the only piece of global state that is shared between clients.
Fields§
§input_dispatcher: InputDispatcher
Decode and dispatch Scenic input events.
xdg_surfaces: Vec<ObjectRef<XdgSurface>>
XDG surfaces. Last surface created at the back.
Implementations§
source§impl Client
impl Client
pub fn new_local( sender: UnboundedSender<MessageBuf>, receiver: UnboundedReceiver<MessageBuf>, display: Display, ) -> Self
sourcepub fn set_protocol_logging(&mut self, enabled: bool)
pub fn set_protocol_logging(&mut self, enabled: bool)
Enables or disables protocol message logging.
sourcepub fn task_queue(&self) -> TaskQueue
pub fn task_queue(&self) -> TaskQueue
Returns a object that can post messages to the Client
.
sourcepub fn event_queue(&self) -> &EventQueue
pub fn event_queue(&self) -> &EventQueue
Returns an object that can post events back to the client.
sourcepub fn start(self)
pub fn start(self)
Spawns an async task that waits for messages to be received on the zircon channel, decodes the messages, and dispatches them to the corresponding |MessageReceiver|s.
sourcepub fn get_object<T: Any>(&self, id: ObjectId) -> Result<&T, ObjectLookupError>
pub fn get_object<T: Any>(&self, id: ObjectId) -> Result<&T, ObjectLookupError>
Looks up an object in the map and returns a downcasted reference to the implementation.
sourcepub fn try_get_object<T: Any>(&self, id: ObjectId) -> Option<&T>
pub fn try_get_object<T: Any>(&self, id: ObjectId) -> Option<&T>
Looks up an object in the map and returns a downcasted reference to the implementation, if it exists.
sourcepub fn get_object_mut<T: Any>(
&mut self,
id: ObjectId,
) -> Result<&mut T, ObjectLookupError>
pub fn get_object_mut<T: Any>( &mut self, id: ObjectId, ) -> Result<&mut T, ObjectLookupError>
Looks up an object in the map and returns a downcasted mutable reference to the implementation.
sourcepub fn try_get_object_mut<T: Any>(&mut self, id: ObjectId) -> Option<&mut T>
pub fn try_get_object_mut<T: Any>(&mut self, id: ObjectId) -> Option<&mut T>
Looks up an object in the map and returns a downcasted mutable reference to the implementation, if it exists.
sourcepub fn add_object<I: Interface + 'static, R: RequestReceiver<I> + 'static>(
&mut self,
id: u32,
receiver: R,
) -> Result<ObjectRef<R>, Error>
pub fn add_object<I: Interface + 'static, R: RequestReceiver<I> + 'static>( &mut self, id: u32, receiver: R, ) -> Result<ObjectRef<R>, Error>
Adds a new object into the map that will handle messages with the sender set to |id|. When a message is received with the corresponding |id|, the message will be decoded and forwarded to the |RequestReceiver|.
Returns Err if there is already an object for |id| in this |ObjectMap|.
sourcepub fn add_object_raw(
&mut self,
id: ObjectId,
receiver: Box<dyn MessageReceiver>,
request_spec: &'static MessageGroupSpec,
) -> Result<(), Error>
pub fn add_object_raw( &mut self, id: ObjectId, receiver: Box<dyn MessageReceiver>, request_spec: &'static MessageGroupSpec, ) -> Result<(), Error>
Adds an object to the map using the low-level primitives. It’s favorable to use instead |add_object| if the wayland interface for the object is statically known.
sourcepub fn delete_id(&mut self, id: ObjectId) -> Result<(), Error>
pub fn delete_id(&mut self, id: ObjectId) -> Result<(), Error>
Deletes the object id
from the local object map and send a notification to the
client confirming that id
can be reused.