From 496cdc9af2dd153bc1bcb2004aea1354979cdfb9 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Fri, 29 Jan 2021 10:54:53 +0530 Subject: [PATCH] docs --- .github/workflows/linux.yml | 15 +++++++++ README.md | 1 + src/lib.rs | 66 +++++++++++++++++++++++++++++-------- 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 13f1e54..01e2358 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -63,3 +63,18 @@ jobs: uses: codecov/codecov-action@v1 with: file: cobertura.xml + + - name: generate documentation + if: matrix.version == 'stable' && (github.repository == 'realaravinth/damn-vuln-blockchain') + uses: actions-rs/cargo@v1 + with: + command: doc + args: --no-deps --workspace --all-features + + - name: Deploy to GitHub Pages + if: matrix.version == 'stable' && (github.repository == 'realaravinth/damn-vuln-blockchain') + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: target/doc diff --git a/README.md b/README.md index 67e10a3..bbde19b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@

+[![Documentation](https://img.shields.io/badge/docs-master-blue)](https://realaravinth.github.io/argon2-creds/argon2_creds/index.html) ![CI (Linux)]() [![dependency status](https://deps.rs/repo/github/realaravinth/argon2-creds/status.svg)](https://deps.rs/repo/github/realaravinth/argon2-creds)
diff --git a/src/lib.rs b/src/lib.rs index 8d03aab..1606ab6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,25 +3,65 @@ //! //! ## Example //! +//! 1. The easiest way to use this crate is with the default configuration. See `Default` +//! implementation for the default configuration. +//! //! ```rust //! use argon2_creds::Config; //! //! fn main() { -//! let username = "iamBatman"; -//! let password = "ironmansucks"; -//! let email = "iambatman@wayne.org"; +//! let config = Config::default(); //! -//! let config = Config::default(); -//! let hash = config.password(password).unwrap(); -//! config.email(Some("batman@we.net")).unwrap(); -//! let username = config.username("Realaravinth").unwrap(); -//! let hash = config.password(password).unwrap(); -//! assert_eq!(username, "realaravinth"); -//! assert!(Config::verify(&hash, password).unwrap(), "verify hahsing"); +//! let password = "ironmansucks"; +//! let hash = config.password(password).unwrap(); //! +//! // email validation +//! config.email(Some("batman@we.net")).unwrap(); +//! +//! // process username +//! let username = config.username("Realaravinth").unwrap(); // process username +//! +//! // generate hash +//! let hash = config.password(password).unwrap(); +//! +//! assert_eq!(username, "realaravinth"); +//! assert!(Config::verify(&hash, password).unwrap(), "verify hahsing"); //! } //! ``` //! +//! 2. To gain fine-grained control over how credentials are managed, consider using +//! [ConfigBuilder]: +//! +//!```rust +//! use argon2_creds::{ConfigBuilder, Config}; +//! +//! fn main() { +//! let config = ConfigBuilder::default() +//! .salt_length(32) +//! .username_case_mapped(false) +//! .profanity(true) +//! .blacklist(false) +//! .argon2(argon2::Config::default()) +//! .build() +//! .unwrap(); +//! +//! let password = "ironmansucks"; +//! let hash = config.password(password).unwrap(); +//! +//! // email validation +//! config.email(Some("batman@we.net")).unwrap(); +//! +//! // process username +//! let username = config.username("Realaravinth").unwrap(); // process username +//! +//! // generate hash +//! let hash = config.password(password).unwrap(); +//! +//! assert_eq!(username, "realaravinth"); +//! assert!(Config::verify(&hash, password).unwrap(), "verify hahsing"); +//! } +//!``` +//! //! ## Documentation & Community Resources //! //! In addition to this API documentation, other resources are available: @@ -32,9 +72,7 @@ //! //! * [Config]: This struct is the entry point to `argon2_creds` //! -//! * [User]: This struct represents a fully processed credentials -//! -//! * [Error]: This module provides essential types for errors that can occour during +//! * [CredsError]: This module provides essential types for errors that can occour during //! credential processing //! //! ## Features @@ -52,5 +90,5 @@ pub mod config; pub mod errors; mod filters; -pub use crate::config::Config; +pub use crate::config::{Config, ConfigBuilder}; pub use crate::errors::{CredsError, CredsResult};