queue

Function queue 

Source
pub fn queue(proxy: &impl UntypedOwnedProxyWrapper) -> &Queue
Expand description

Returns the queue of a proxy.

ยงExample

let lib = Libwayland::open().unwrap();
let con = lib.connect_to_default_display().unwrap();

let queue = con.create_queue(c"");
let display: WlDisplay = queue.display();
assert_eq!(proxy::queue(&display), &*queue);
Examples found in repository?
examples/async-wait/main.rs (line 30)
23fn create_sync(queue: &Queue, n: u64) {
24    let sync = queue.display::<WlDisplay>().sync();
25    proxy::set_event_handler(
26        &sync.clone(),
27        WlCallback::on_done(move |_, _| {
28            println!("done! ({n})");
29            proxy::destroy(&sync);
30            create_sync(proxy::queue(&sync), n + 1);
31        }),
32    );
33}
More examples
Hide additional examples
examples/poll-integration/main.rs (line 55)
48fn create_sync(queue: &Queue, n: u64) {
49    let sync = queue.display::<WlDisplay>().sync();
50    proxy::set_event_handler(
51        &sync.clone(),
52        WlCallback::on_done(move |_, _| {
53            println!("done! ({n})");
54            proxy::destroy(&sync);
55            create_sync(proxy::queue(&sync), n + 1);
56        }),
57    );
58}
examples/simple-window/../common/singletons.rs (line 59)
56pub fn get_singletons(display: &WlDisplay) -> Singletons {
57    let map = Mutex::new(HashMap::new());
58
59    let queue = proxy::queue(display);
60    let wl_registry = display.get_registry();
61
62    queue.dispatch_scope_blocking(|scope| {
63        scope.set_event_handler(
64            &wl_registry,
65            WlRegistry::on_global(|_, name, interface, version| {
66                map.lock().insert(interface.to_owned(), (name, version));
67            }),
68        );
69        queue.dispatch_roundtrip_blocking().unwrap();
70    });
71
72    Singletons {
73        wl_registry,
74        map: map.into_inner(),
75    }
76}
77
78pub async fn get_singletons_async(display: &WlDisplay) -> Singletons {
79    let map = Mutex::new(HashMap::new());
80
81    let queue = proxy::queue(display);
82    let wl_registry = display.get_registry();
83
84    queue
85        .dispatch_scope_async(async |scope| {
86            scope.set_event_handler(
87                &wl_registry,
88                WlRegistry::on_global(|_, name, interface, version| {
89                    map.lock().insert(interface.to_owned(), (name, version));
90                }),
91            );
92            queue.dispatch_roundtrip_async().await.unwrap();
93        })
94        .await;
95
96    Singletons {
97        wl_registry,
98        map: map.into_inner(),
99    }
100}