Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lur1an committed Jul 18, 2024
1 parent 27473ef commit 9684608
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,13 @@ impl Actor for MyActor {

struct Document;

#[derive(IntoStaticStr)]
#[strum(serialize_all = "snake_case")]
pub enum DocumentPermission {
Read,
Write,
}

impl Permission for DocumentPermission {
fn name(&self) -> &'static str {
match self {
DocumentPermission::Read => "read",
DocumentPermission::Write => "write",
}
}
}

impl Entity for Document {
type Relations = DocumentRelation;
type Id = String;
Expand All @@ -92,26 +85,19 @@ impl Entity for Document {
}
}

#[derive(IntoStaticStr)]
#[strum(serialize_all = "snake_case")]
pub enum DocumentRelation {
Reader,
Writer,
}

impl Relation for DocumentRelation {
fn name(&self) -> &'static str {
match self {
DocumentRelation::Reader => "reader",
DocumentRelation::Writer => "writer",
}
}
}

impl Resource for Document {
type Permissions = DocumentPermission;
}

```
> **_NOTE:_** Will be working on some `strum` integration to cut down on the quite obvious boilerplate that turns the enum variants into strings.
> **_NOTE:_** The boilerplate for `Relations` and `Permissions` is gone thanks to the `IntoStaticStr` macro from the `strum` crate, this crate also re-exports it.
This type system now makes it impossible to check for a permission that doesn't exist, or create a relationship not supported for an entity.

Expand Down

0 comments on commit 9684608

Please sign in to comment.