-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from manomayam/feat-docs-up
feat: add readme for fcrates
- Loading branch information
Showing
18 changed files
with
220 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# acp | ||
|
||
An implementation of [access control policy](https://solid.github.io/authorization-panel/acp-specification/) concepts and engine for rust. | ||
|
||
|
||
License: MIT OR Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# capped_stream | ||
|
||
This crate provides types for size capped streams. | ||
|
||
|
||
License: MIT OR Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# dpop | ||
|
||
This crate provides rust implementation of [DPoP](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop-14). | ||
|
||
|
||
License: MIT OR Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# gdp_rs | ||
|
||
This crate provides utilities to employ [Ghosts-of-Departed-Proofs](https://kataskeue.com/gdp.pdf) | ||
pattern in rust projects. | ||
This enables type drive development following [Parse, don't validate](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/) principle. | ||
|
||
The idea is that, instead of checking or validating the values of a Type for | ||
satisfying certain properties, one create a wrapper refined new type that | ||
can only constructed from the values satisfying desired predicates. | ||
Thus, one can centralize the validation mechanism, and use typesystem to | ||
enforce right invariant. | ||
|
||
This crate provides a type [`Proven`], which is generic over the predicate type. | ||
It can be instantiated only from valid subject values of a type, satisfying the | ||
predicate function. | ||
|
||
The crate also provides combinatrics over multiple predicates, so that one | ||
compose a compound predicate type from list of other predicate type. | ||
|
||
|
||
License: MIT OR Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//! This example demonstrates on creating a refinement type satisfying a single predicate. | ||
//! | ||
use gdp_rs::{ | ||
predicate::{Predicate, PurePredicate, SyncEvaluablePredicate}, | ||
Proven, | ||
}; | ||
|
||
/// A struct for representing a password, that allows arbitrary string value. | ||
struct Password { | ||
value: String, | ||
} | ||
|
||
/// A predicate type overt [`Password`], that checks if it is strong. | ||
#[derive(Debug)] | ||
struct IsStrong {} | ||
|
||
// Implement predicate contract over subject values of [``Password`] type. | ||
impl Predicate<Password> for IsStrong { | ||
fn label() -> std::borrow::Cow<'static, str> { | ||
"IsStrong".into() | ||
} | ||
} | ||
|
||
impl SyncEvaluablePredicate<Password> for IsStrong { | ||
type EvalError = IsNotStrong; | ||
|
||
fn evaluate_for(sub: &Password) -> Result<(), Self::EvalError> { | ||
let p = &sub.value; | ||
// We have simple check of length for password strength. | ||
if p.len() >= 8 { | ||
Ok(()) | ||
} else { | ||
Err(IsNotStrong) | ||
} | ||
} | ||
} | ||
|
||
/// Mark predicate as pure. | ||
impl PurePredicate<Password> for IsStrong {} | ||
|
||
/// Define alias for refined new type. | ||
type StrongPassword = Proven<Password, IsStrong>; | ||
|
||
/// Now use the newtype. No need of further validation inside the function. | ||
fn set_password(_username: String, _password: StrongPassword) { | ||
// ... | ||
} | ||
|
||
/// Error type for predicate. | ||
#[derive(Debug, thiserror::Error)] | ||
#[error("Given password is not a strong password")] | ||
struct IsNotStrong; | ||
|
||
fn main() { | ||
let password_input = Password { | ||
value: "anc1234f".into(), | ||
}; | ||
|
||
let validated_password = StrongPassword::try_new(password_input).unwrap_or_else(|e| { | ||
let sub = e.subject; | ||
panic!("Entered password {} is not strong", sub.value); | ||
}); | ||
|
||
set_password("username".into(), validated_password); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# http_typed_headers | ||
|
||
This crate provides few typed http headers. | ||
|
||
|
||
License: MIT OR Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# http_uri | ||
|
||
This crate provides types for representing http uris and their invariants. | ||
|
||
|
||
License: MIT OR Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# name_locker | ||
|
||
This crate defines trait for asynchronous name lockers, | ||
that can run an async task with advisory-lock on a given name. | ||
|
||
It also provides a default inmemory implementation. | ||
|
||
|
||
License: MIT OR Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters