cargo_metadata
cargo_metadata copied to clipboard
Provide a way to construct a default Package
Right now, I'm working with this monstrosity:
let package = serde_json::from_value(serde_json::json!({
"packages": [
/*
{
"name": "doom-rustdoc",
"version": "1.0.0",
"id": "doom-rustdoc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"license": "Unlicense",
"license_file": null,
"description": "Doom running in Rustdoc",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"dependencies": [],
"targets": [
{
"kind": [
"lib"
],
"crate_types": [
"lib"
],
"name": "doom-rustdoc",
//"src_path": "/home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/doom-rustdoc-1.0.0/src/lib.rs",
"edition": "2018",
"doc": true,
"doctest": true,
"test": true
}
],
"features": {},
//"manifest_path": "/home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/doom-rustdoc-1.0.0/Cargo.toml",
"metadata": null,
"publish": null,
"authors": [
//"Kestrer <[email protected]>"
],
"categories": [],
"keywords": [],
"readme": null,
"repository": null,
"homepage": null,
"documentation": null,
"edition": "2018",
"links": null
},
*/
{
"name": "hello-world",
"version": "0.1.0",
//"id": "hello-world 0.1.0 (path+file:///home/joshua/src/rust/hello-world)",
"license": null,
"license_file": null,
"description": null,
"source": null,
"dependencies": [
{
"name": "doom-rustdoc",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"req": "^1",
"kind": null,
"rename": null,
"optional": false,
"uses_default_features": true,
"features": [],
"target": null,
"registry": null
}
],
"targets": [
{
"kind": [
"bin"
],
"crate_types": [
"bin"
],
"name": "hello-world",
//"src_path": "/home/joshua/src/rust/hello-world/src/main.rs",
"edition": "2018",
"doc": true,
"doctest": false,
"test": true
}
],
"features": {},
//"manifest_path": "/home/joshua/src/rust/hello-world/Cargo.toml",
"metadata": null,
"publish": null,
"authors": [],
"categories": [],
"keywords": [],
"readme": null,
"repository": null,
"homepage": null,
"documentation": null,
"edition": "2018",
"links": null
}
],
"workspace_members": [
//"hello-world 0.1.0 (path+file:///home/joshua/src/rust/hello-world)"
],
"resolve": {
"nodes": [
{
"id": "doom-rustdoc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dependencies": [],
"deps": [],
"features": []
},
{
"id": "hello-world 0.1.0 (path+file:///home/joshua/src/rust/hello-world)",
"dependencies": [
"doom-rustdoc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)"
],
"deps": [
{
"name": "doom_rustdoc",
"pkg": "doom-rustdoc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dep_kinds": [
{
"kind": null,
"target": null
}
]
}
],
"features": []
}
],
"root": "hello-world 0.1.0 (path+file:///home/joshua/src/rust/hello-world)"
},
//"target_directory": "/home/joshua/.local/lib/cargo/target",
//"version": 1,
"workspace_root": "hello-world",
"metadata": null
}))
.unwrap();
It would be nice to have a way to default construct a Package instead.
I just had a look and found there is a builder
feature that uses the derive_builder
crate to generate a builder for some types like Package
, does that help?