22 unstable releases (4 breaking)

0.5.0 Oct 19, 2024
0.3.2 Sep 24, 2024
0.3.0 Mar 29, 2024
0.2.7 Dec 18, 2023
0.1.6 Nov 26, 2023

#1485 in Web programming

Download history 210/week @ 2024-08-17 221/week @ 2024-08-24 159/week @ 2024-08-31 176/week @ 2024-09-07 95/week @ 2024-09-14 681/week @ 2024-09-21 329/week @ 2024-09-28 133/week @ 2024-10-05 148/week @ 2024-10-12 460/week @ 2024-10-19 214/week @ 2024-10-26 99/week @ 2024-11-02 510/week @ 2024-11-09 749/week @ 2024-11-16 112/week @ 2024-11-23 77/week @ 2024-11-30

1,450 downloads per month
Used in 2 crates (via launchpadlib)

Apache-2.0 and maybe GPL-3.0+

135KB
3.5K SLoC

This crate contains a parser for the Web Application Description Language (WADL).

It can also generate basic rust bindings based on WADL files, if the codegen feature is enabled.

Example usage

Simply parsing the ast

let app: wadl::ast::Application = wadl::parse_file("1.0.wadl").unwrap();

println!("{:#}", app);

Generating code

Create a build.rs that generates rust code:

fn main() {
    let config = wadl::codegen::Config {
        // Set extra options here to influence code generation,
        // e.g. to rename functions.
        ..Default::default()
    };

    let wadl = std::fs::read_to_string(
            concat!(env!("CARGO_MANIFEST_DIR"), "/x.wadl")).unwrap();

    let wadl_app = wadl::parse_string(wadl.as_str()).unwrap();
    let code = wadl::codegen::generate(&wadl_app, &config);
    let target_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap())
        .canonicalize()
        .unwrap();
    let generated = target_dir.join("generated");
    std::fs::create_dir_all(&generated).unwrap();
    let path = generated.join("x.wadl");
    std::fs::write(path, code).unwrap();
}

Then, you can include the generated code from your rust code:

include!(concat!(env!("OUT_DIR"), "/generated/x.rs"));

Dependencies

~5–17MB
~232K SLoC