Crates.io | crate-metadata |
lib.rs | crate-metadata |
version | 0.1.1 |
source | src |
created_at | 2022-10-05 12:13:11.682426 |
updated_at | 2023-04-22 18:35:41.381938 |
description | Utility functions to get current crate metadata. |
homepage | https://github.com/boozook/crate-metadata |
repository | https://github.com/boozook/crate-metadata.git |
max_upload_size | |
id | 680481 |
size | 10,561 |
For usage from build-script.
Utility functions that returns current crate metadata
as result of call cargo metadata
.
Cargo.toml:
# ...
[package.metadata]
foo = "bar"
# ...
build.rs
extern crate serde;
extern crate serde_json;
extern crate crate_metadata;
use serde::Deserialize;
fn main() {
let metadata = crate_metadata::crate_metadata::<MyMeta>().unwrap();
assert_eq!("bar", &metadata.packages.first().unwrap().metadata.unwrap().foo);
}
#[derive(Deserialize, Debug)]
struct MyMeta {
pub foo: String,
}