#wayland #codegen

macro build wayland-scanner

Wayland Scanner for generating rust APIs from XML wayland protocol files

128 releases

new 0.30.0-beta.7 Jul 4, 2022
0.30.0-beta.3 May 27, 2022
0.30.0-alpha9 Mar 29, 2022
0.29.1 Oct 17, 2021
0.2.0 Nov 19, 2015

#306 in GUI

Download history 24776/week @ 2022-03-14 27233/week @ 2022-03-21 25973/week @ 2022-03-28 29124/week @ 2022-04-04 27840/week @ 2022-04-11 26728/week @ 2022-04-18 26921/week @ 2022-04-25 26671/week @ 2022-05-02 26851/week @ 2022-05-09 26419/week @ 2022-05-16 25218/week @ 2022-05-23 26500/week @ 2022-05-30 27662/week @ 2022-06-06 27065/week @ 2022-06-13 24294/week @ 2022-06-20 24127/week @ 2022-06-27

106,659 downloads per month
Used in 524 crates (13 directly)

MIT license

82KB
2K SLoC

crates.io docs.rs Continuous Integration codecov

wayland-scanner

This crate provides procedural macros for generating the rust code associated with a Wayland XML protocol specification, for use with the wayland-client, wayland-server and wayland-backend crates.

Before trying to use this crate, you may check if the protocol extension you want to use is not already exposed in the wayland-protocols crate.


lib.rs:

Wayland protocol code-generation machinnery

This crate provides procedural macros for generating the rust code associated with a Wayland XML protocol specification, for use with the wayland-client, wayland-server and wayland-backend crates.

Before trying to use this crate, you may check if the protocol extension you want to use is not already exposed in the wayland-protocols crate.

Example usage

Below is a template for generating the code for a custom protocol client-side. Server-side is identical, just replacing client by server. The path to the XML file is relative to the crate root.

// Generate the bindings in their own module
pub mod my_protocol {
    use wayland_client;
    // import objects from the core protocol if needed
    use wayland_client::protocol::*;

    // This module hosts a low-level representation of the protocol objects
    // you will not need to interact with it yourself, but the code generated
    // by the generate_client_code! macro will use it
    pub mod __interfaces {
        // import the interfaces from the core protocol if needed
        use wayland_client::protocol::__interfaces::*;
        wayland_scanner::generate_interfaces!("./path/to/the/protocol.xml");
    }
    use self::__interfaces::*;

    // This macro generates the actual types that represent the wayland objects of
    // your custom protocol
    wayland_scanner::generate_client_code!("./path/to/the/protocol.xml");
}

Dependencies

~215–295KB