Struct wayland_client::protocol::wl_registry::WlRegistry
source · pub struct WlRegistry { /* private fields */ }
Expand description
global registry object
The singleton global registry object. The server has a number of global objects that are available to all clients. These objects typically represent an actual object in the server (for example, an input device) or they are singleton objects that provide extension functionality.
When a client creates a registry object, the registry object will emit a global event for each global currently in the registry. Globals come and go as a result of device or monitor hotplugs, reconfiguration or other events, and the registry will send out global and global_remove events to keep the client up to date with the changes. To mark the end of the initial burst of events, the client can use the wl_display.sync request immediately after calling wl_display.get_registry.
A client can bind to a global object by using the bind request. This creates a client-side handle that lets the object emit events to the client and lets the client invoke requests on the object.
See also the Event enum for this interface.
Implementations§
source§impl WlRegistry
impl WlRegistry
sourcepub fn bind<I: Proxy + 'static, U: Send + Sync + 'static, D: Dispatch<I, U> + 'static>(
&self,
name: u32,
version: u32,
qh: &QueueHandle<D>,
udata: U
) -> I
pub fn bind<I: Proxy + 'static, U: Send + Sync + 'static, D: Dispatch<I, U> + 'static>(
&self,
name: u32,
version: u32,
qh: &QueueHandle<D>,
udata: U
) -> I
bind an object to the display
Binds a new, client-created object to the server using the specified name as the identifier.
Examples found in repository?
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
pub fn bind<I, State, U>(
&self,
qh: &QueueHandle<State>,
version: RangeInclusive<u32>,
udata: U,
) -> Result<I, BindError>
where
I: Proxy + 'static,
State: Dispatch<I, U> + 'static,
U: Send + Sync + 'static,
{
let version_start = *version.start();
let version_end = *version.end();
let interface = I::interface();
if *version.end() > interface.version {
// This is a panic because it's a compile-time programmer error, not a runtime error.
panic!("Maximum version ({}) of {} was higher than the proxy's maximum version ({}); outdated wayland XML files?",
version.end(), interface.name, interface.version);
}
let globals = &self.registry.data::<GlobalListContents>().unwrap().contents;
let guard = globals.lock().unwrap();
let (name, version) = guard
.iter()
// Find the with the correct interface
.filter_map(|Global { name, interface: interface_name, version }| {
// TODO: then_some
if interface.name == &interface_name[..] {
Some((*name, *version))
} else {
None
}
})
.next()
.ok_or(BindError::NotPresent)?;
// Test version requirements
if version < version_start {
return Err(BindError::UnsupportedVersion);
}
// To get the version to bind, take the lower of the version advertised by the server and the maximum
// requested version.
let version = version.min(version_end);
Ok(self.registry.bind(name, version, qh, udata))
}
Trait Implementations§
source§impl Clone for WlRegistry
impl Clone for WlRegistry
source§fn clone(&self) -> WlRegistry
fn clone(&self) -> WlRegistry
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for WlRegistry
impl Debug for WlRegistry
source§impl PartialEq<Weak<WlRegistry>> for WlRegistry
impl PartialEq<Weak<WlRegistry>> for WlRegistry
source§impl PartialEq<WlRegistry> for WlRegistry
impl PartialEq<WlRegistry> for WlRegistry
source§fn eq(&self, other: &WlRegistry) -> bool
fn eq(&self, other: &WlRegistry) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Proxy for WlRegistry
impl Proxy for WlRegistry
source§fn data<U: Send + Sync + 'static>(&self) -> Option<&U>
fn data<U: Send + Sync + 'static>(&self) -> Option<&U>
source§fn object_data(&self) -> Option<&Arc<dyn ObjectData>>
fn object_data(&self) -> Option<&Arc<dyn ObjectData>>
source§fn backend(&self) -> &WeakBackend
fn backend(&self) -> &WeakBackend
source§fn send_request(&self, req: Self::Request) -> Result<(), InvalidId>
fn send_request(&self, req: Self::Request) -> Result<(), InvalidId>
source§fn send_constructor<I: Proxy>(
&self,
req: Self::Request,
data: Arc<dyn ObjectData>
) -> Result<I, InvalidId>
fn send_constructor<I: Proxy>(
&self,
req: Self::Request,
data: Arc<dyn ObjectData>
) -> Result<I, InvalidId>
source§fn from_id(conn: &Connection, id: ObjectId) -> Result<Self, InvalidId>
fn from_id(conn: &Connection, id: ObjectId) -> Result<Self, InvalidId>
source§fn inert(backend: WeakBackend) -> Self
fn inert(backend: WeakBackend) -> Self
source§fn parse_event(
conn: &Connection,
msg: Message<ObjectId, OwnedFd>
) -> Result<(Self, Self::Event), DispatchError>
fn parse_event(
conn: &Connection,
msg: Message<ObjectId, OwnedFd>
) -> Result<(Self, Self::Event), DispatchError>
source§fn write_request(
&self,
conn: &Connection,
msg: Self::Request
) -> Result<(Message<ObjectId, RawFd>, Option<(&'static Interface, u32)>), InvalidId>
fn write_request(
&self,
conn: &Connection,
msg: Self::Request
) -> Result<(Message<ObjectId, RawFd>, Option<(&'static Interface, u32)>), InvalidId>
impl Eq for WlRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for WlRegistry
impl Send for WlRegistry
impl Sync for WlRegistry
impl Unpin for WlRegistry
impl !UnwindSafe for WlRegistry
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.