An open API service indexing awesome lists of open source software.

https://github.com/boozook/crate-metadata

Utility functions to get current crate metadata.
https://github.com/boozook/crate-metadata

build-script cargo crate metadata utility

Last synced: 4 months ago
JSON representation

Utility functions to get current crate metadata.

Awesome Lists containing this project

README

          

# Cargo Crate Metadata

__For usage from build-script.__

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

## Example

_Cargo.toml:_
```toml
# ...

[package.metadata]
foo = "bar"

# ...
```

_build.rs_
```rust
extern crate serde;
extern crate serde_json;
extern crate crate_metadata;

use serde::Deserialize;

fn main() {
let metadata = crate_metadata::crate_metadata::().unwrap();
assert_eq!("bar", &metadata.packages.first().unwrap().metadata.unwrap().foo);
}

#[derive(Deserialize, Debug)]
struct MyMeta {
pub foo: String,
}
```