pub struct EvalTrace { /* private fields */ }
Expand description
Container for the evaluation tree Detailed trace of all policy evaluations
Implementations§
Source§impl EvalTrace
impl EvalTrace
pub fn new() -> Self
pub fn with_root(result: PolicyEvalResult) -> Self
pub fn set_root(&mut self, result: PolicyEvalResult)
pub fn root(&self) -> Option<&PolicyEvalResult>
Sourcepub fn format(&self) -> String
pub fn format(&self) -> String
Returns a formatted representation of the evaluation tree
Examples found in repository?
examples/rbac_policy.rs (line 212)
186async fn test_access(
187 checker: &PermissionChecker<User, Document, ReadAction, EmptyContext>,
188 user_desc: &str,
189 user: &User,
190 doc_desc: &str,
191 doc: &Document,
192) {
193 let context = EmptyContext;
194 let action = ReadAction;
195
196 let result = checker.evaluate_access(user, &action, doc, &context).await;
197
198 println!(
199 "{} accessing {}: {}",
200 user_desc,
201 doc_desc,
202 if result.is_granted() {
203 "GRANTED ✓"
204 } else {
205 "DENIED ✗"
206 }
207 );
208
209 println!(
210 "Evaluation trace:\n{}\n",
211 match &result {
212 AccessEvaluation::Granted { trace, .. } => trace.format(),
213 AccessEvaluation::Denied { trace, .. } => trace.format(),
214 }
215 );
216}
More examples
examples/rebac_policy.rs (line 238)
212async fn test_access(
213 checker: &PermissionChecker<User, Project, EditAction, EmptyContext>,
214 user: &User,
215 project: &Project,
216) {
217 let context = EmptyContext;
218 let action = EditAction;
219
220 println!("\nChecking if {} can edit {}:", user.name, project.name);
221 let result = checker
222 .evaluate_access(user, &action, project, &context)
223 .await;
224
225 println!(
226 "Access {} for {}",
227 if result.is_granted() {
228 "GRANTED ✓"
229 } else {
230 "DENIED ✗"
231 },
232 user.name
233 );
234
235 println!(
236 "Evaluation trace:\n{}\n",
237 match &result {
238 AccessEvaluation::Granted { trace, .. } => trace.format(),
239 AccessEvaluation::Denied { trace, .. } => trace.format(),
240 }
241 );
242}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EvalTrace
impl RefUnwindSafe for EvalTrace
impl Send for EvalTrace
impl Sync for EvalTrace
impl Unpin for EvalTrace
impl UnwindSafe for EvalTrace
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more