#cargo-metadata #metadata #cargo #crates #cargo-toml

build crate-metadata

Utility functions to get current crate metadata

2 releases

0.1.1 Apr 22, 2023
0.1.0 Oct 5, 2022

#424 in Build Utils

Download history 15/week @ 2024-01-11 3/week @ 2024-01-18 5/week @ 2024-02-01 36/week @ 2024-02-08 22/week @ 2024-02-15 44/week @ 2024-02-22 37/week @ 2024-02-29 51/week @ 2024-03-07 60/week @ 2024-03-14 31/week @ 2024-03-21 152/week @ 2024-03-28 115/week @ 2024-04-04 137/week @ 2024-04-11 64/week @ 2024-04-18 79/week @ 2024-04-25

431 downloads per month
Used in 6 crates (3 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.7–1.4MB
~33K SLoC