| Crates.io | vaultrs |
| lib.rs | vaultrs |
| version | 0.7.4 |
| created_at | 2021-08-22 20:32:50.187112+00 |
| updated_at | 2025-02-21 16:43:36.227967+00 |
| description | An asynchronous Rust client library for the Hashicorp Vault API. |
| homepage | |
| repository | https://github.com/jmgilman/vaultrs |
| max_upload_size | |
| id | 440841 |
| size | 525,973 |
An asynchronous Rust client library for the Hashicorp Vault API
The following features are currently supported:
See something missing? Open an issue.
First, choose one of the two TLS implementations for vaultrs' connection to
Vault:
rustls (default) to use Rustlsnative-tls to use
rust-native-tls, which builds
on your platform-specific TLS implementation.Then, add vaultrs as a dependency to your cargo.toml:
[dependencies]
vaultrs = "0.7.4"
[dependencies]
vaultrs = { version = "0.7.4", default-features = false, features = [ "native-tls" ] }
The client is used to configure the connection to Vault and is required to be passed to all API calls for execution. Behind the scenes it uses an asynchronous client from Reqwest for communicating to Vault.
use vaultrs::client::{VaultClient, VaultClientSettingsBuilder};
// Create a client
let client = VaultClient::new(
VaultClientSettingsBuilder::default()
.address("https://127.0.0.1:8200")
.token("TOKEN")
.build()
.unwrap()
).unwrap();
For more usages, take a look at the documentation
All errors generated by this crate are wrapped in the ClientError enum
provided by the crate. API warnings are automatically captured via tracing and
API errors are captured and returned as their own variant. Connection related
errors from rustify are wrapped and returned as a single variant.
All top level API operations are instrumented with tracing's #[instrument]
attribute.
See the the tests directory for tests. Run tests with cargo test.
Note: All tests rely on bringing up a local Vault development server using Docker. In order to run tests Docker must be running locally (Docker Desktop works). The first run will be longer than other because it will fetch images.
Some long-running tests are ignored by default locally. To run them do:
cargo test -- --include-ignored
Check out the issues for items needing attention or submit your own and then:
See CONTRIBUTING for extensive documentation on the architecture of this library and how to add additional functionality to it.