https://github.com/teddy-van-jerry/doi-rs
Digital Object Identifier (DOI) resolver for Rust
https://github.com/teddy-van-jerry/doi-rs
doi resolver rust
Last synced: 12 days ago
JSON representation
Digital Object Identifier (DOI) resolver for Rust
- Host: GitHub
- URL: https://github.com/teddy-van-jerry/doi-rs
- Owner: Teddy-van-Jerry
- License: mit
- Created: 2024-08-24T08:55:03.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-08T21:52:34.000Z (about 1 year ago)
- Last Synced: 2025-07-28T05:51:14.393Z (2 months ago)
- Topics: doi, resolver, rust
- Language: Rust
- Homepage: https://docs.rs/doi
- Size: 55.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# DOI for Rust
Digital Object Identifier (DOI) resolver for RustThis crate provides a simple way to resolve DOIs and retrieve metadata
using the [DOI](https://www.doi.org) APIs.## Basic Usage
The following is a basic example of using this library:
```rust
use doi::Doi;
let doi = Doi::new("10.1109/TCSII.2024.3366282");
match doi.resolve() {
Ok(resolved) => println!("Resolved Link: {}", resolved),
Err(e) => eprintln!("Error: {}", e),
}
```
Please refer to the API documentation for more information.
More complicated constructions can be done using the `DoiBuilder` struct.## Metadata
This library also provides a way to retrieve metadata for a DOI.
The `metadata` feature is required to use this functionality (enabled by default).### Structured Metadata
The structured metadata can be retrieved using the `metadata` method.
```rust
use doi::Doi;
let doi = Doi::new("10.1109/TCSII.2024.3366282");
match doi.metadata() {
Ok(metadata) => println!("Paper Title: {}", metadata.title.unwrap_or("".to_string())),
Err(e) => eprintln!("Error: {}", e),
}
```Supported metadata fields:
| Field | Type | Description |
| --- | --- | --- |
| `title` | `Option` | Title of the document |
| `authors` | `Option>` | Author(s) of the document |
| `r#type` | `Option` | Type of the document (e.g., journal, conference) |The `DoiMetadataPerson` struct has the fields `given`, `family`, and `suffix`, which are all `Option`.
The `DoiMetadataType` enum has the `as_str` method to get the string representation.### Raw JSON Metadata
The raw JSON metadata can be retrieved using the `metadata_json` method,
powered by `serde_json`.
```rust
use doi::Doi;
let doi = Doi::new("10.1109/TCSII.2024.3366282");
match doi.metadata_json() {
Ok(metadata) => println!("Metadata: {}", metadata),
Err(e) => eprintln!("Error: {}", e),
}
```The raw JSON string can be obtained via the `metadata_json_string` method.
## Blocking Requests
This library is designed to use blocking I/O,
depending on the [`ureq` library](https://docs.rs/ureq) for HTTP requests.## License
This project is licensed under the [MIT license](LICENSE).