Crates.io | wadl |
lib.rs | wadl |
version | |
source | src |
created_at | 2023-10-15 11:55:58.142056 |
updated_at | 2024-10-19 23:46:13.660514 |
description | A WADL parser for Rust |
homepage | |
repository | https://github.com/jelmer/wadl |
max_upload_size | |
id | 1003678 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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.
let app: wadl::ast::Application = wadl::parse_file("1.0.wadl").unwrap();
println!("{:#}", app);
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"));