https://github.com/bachp/git-credential-rs
Crate that provides types that help to implement git-credential helpers
https://github.com/bachp/git-credential-rs
git git-credential-helper rust rust-crate
Last synced: 8 months ago
JSON representation
Crate that provides types that help to implement git-credential helpers
- Host: GitHub
- URL: https://github.com/bachp/git-credential-rs
- Owner: bachp
- License: apache-2.0
- Created: 2019-08-21T21:48:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-01T07:24:47.000Z (over 2 years ago)
- Last Synced: 2025-01-11T11:19:57.246Z (over 1 year ago)
- Topics: git, git-credential-helper, rust, rust-crate
- Language: Rust
- Size: 19.5 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Git Credential
[](https://actions-badge.atrox.dev/bachp/git-credential-rs/goto?ref=master)
[](https://crates.io/crates/git-credential)
[](https://docs.rs/git-credential)
A Rust library that provides types that help to implement git-credential helpers.
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
git-credential = "*"
```
This crates provides types that are able to parse input and produce output in the format
described in [git-credential[1] ](https://git-scm.com/docs/git-credential).
The following shows an example on how create a `GitCredential` struct
from an input, modify it and write it back to an output:
```rust
use git_credential::GitCredential;
let input = "username=me\npassword=%sec&ret!\n\n".as_bytes();
let mut output: Vec = Vec::new();
let mut g = GitCredential::from_reader(input).unwrap();
assert_eq!(g.username.unwrap(), "me");
assert_eq!(g.password.unwrap(), "%sec&ret!");
g.username = Some("you".into());
g.password = Some("easy".into());
g.to_writer(&mut output).unwrap();
assert_eq!("username=you\npassword=easy\n\n", String::from_utf8(output).unwrap())
```
See the [API documentation](https://docs.rs/git-credential) for more details.
# License
Rand is distributed under the terms of both the MIT license and the
Apache License (Version 2.0).
See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
[COPYRIGHT](COPYRIGHT) for details.