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 5799a97 commit bf266c0
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,37 @@ This type system now makes it impossible to check for a permission that doesn't
Now lets create some relationship and check some permissions!
```rust
let client = SpiceDBClient::new("http://localhost:50051", "randomkey")
.await? ;
let mut request = client.create_relationships_request();
let user_id = uuid::now_v7();
request.add_relationship::<user, document>(
relationshipoperation::touch,
user_id,
None,
"homework",
documentrelation::writer,
);
request.add_wildcard_relationship::<user, document>(
relationshipoperation::touch,
"manga",
documentrelation::reader,
);

let token = request.send().await.unwrap();
let actor = MyActor(user_id);
let authorized = client.check_permission_at::<document>(
&actor,
"homework",
DocumentPermission::Write,
token.clone(),
)
let client = SpiceDBClient::new("http://localhost:50051".to_owned(), "randomkey")
.await?;
let user_id = Uuid::now_v7();
let relationships = [
relationship_update::<User, Document>(
RelationshipOperation::Touch,
user_id,
None,
"homework",
DocumentRelation::Writer,
),
wildcard_relationship_update::<User, Document>(
RelationshipOperation::Touch,
"manga",
DocumentRelation::Reader,
),
];
let token = client
.create_relationships(relationships, [])
.await
.unwrap();
let actor = MyActor(user_id);
let authorized = client.check_permission_at::<Document>(
&actor,
"homework",
DocumentPermission::Write,
token.clone(),
)
.await?;
```

## Mocking
TODO!
Enable the `mock` feature to instead use a client generated by `mockall`.
All public interfaces will work as expected, but not the request builder interfaces, as those are not mocked, if you are using those currently you have to test against a real instance of SpiceDB.

0 comments on commit bf266c0

Please sign in to comment.