2 releases

0.1.1 Apr 22, 2023
0.1.0 Oct 5, 2022

#462 in Build Utils

46 downloads per month
Used in 5 crates (2 directly)

MIT license

7KB
79 lines

Cargo Crate Metadata

For usage from build-script.

Utility functions that returns current crate metadata as result of call cargo metadata.

Example

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,
}

lib.rs:

For usage from build-script.

Utility functions that returns current crate metadata as result of call cargo metadata.

Dependencies

~0.6–1.4MB
~32K SLoC