Permeable

Permeable is a permission-demand trait. It helps to decouple the permission-demander from the permission / auth provider.

Our goal was the simplest possible trait to ask for permission. Can be implemented by a permission-provider distinguishing between users.

Example

```rust use permeable::{Permeable, PermissionError};

const ROTHIS: &str = "RoThis"; const RWTHIS: &str = "RwThis"; const ACCESS_THAT: &str = "AccessThat";

struct User { name: String, };

// A naive implementation of a the Permeable-Trait. impl Permeable for User { fn hasperm(&self, permission: &str) -> Result<(), PermissionError> { match (self.name.asstr(), permission) { ("admin", ) => Ok(()), ("peter", ACCESSTHAT) => Ok(()), ("peter", ROTHIS) => Ok(()), ("paul", ROTHIS) => Ok(()), ("paul", RWTHIS) => Ok(()), // catch all (, perm) => Err(PermissionError::denied(format!("{permission}"), &self.name)), } } }

fn main() { let admin = User { name: String::from("admin") }; asserteq!(admin.hasperm(RWTHIS), Ok(())); let peter = User { name: String::from("peter") }; asserteq!(peter.hasperm(ACCESSTHAT), Ok(())); asserteq!(peter.hasperm(RWTHIS).iserr(), true); } ```