As this error is only used for `Permission`, it's clear that it contains a `Permission` instance.
Unified · Split
| @@ -7,18 +7,18 @@ use std::fmt::{Display, Formatter}; · 6 unmodified lines | |||
| 7 | /// causes errors. | 7 | /// causes errors. |
| 8 | #[derive(Debug, thiserror::Error)] | 8 | #[derive(Debug, thiserror::Error)] |
| 9 | #[error("Not allowed to handle resource {:?}: permission {}", .resource, .permission)] | 9 | #[error("Not allowed to handle resource {:?}: permission {}", .resource, .permission)] |
| 10 | pub struct Error<R: std::fmt::Debug, P: std::fmt::Debug + Display> { | 10 | pub struct Error<R: std::fmt::Debug> { |
| 11 | /// The resource which cannot be used. | 11 | /// The resource which cannot be used. |
| 12 | pub resource: R, | 12 | pub resource: R, |
| 13 | /// The permission causing it to be disallowed. | 13 | /// The permission causing it to be disallowed. |
| 14 | pub permission: P, | 14 | pub permission: Permission, |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | impl Permission { | 17 | impl Permission { |
| 18 | /// Check this permissions and produce a reply to indicate if the `resource` can be used and in which way. | 18 | /// Check this permissions and produce a reply to indicate if the `resource` can be used and in which way. |
| 19 | /// | 19 | /// |
| 20 | /// Only if this permission is set to `Allow` will the resource be usable. | 20 | /// Only if this permission is set to `Allow` will the resource be usable. |
| 21 | pub fn check<R: std::fmt::Debug>(&self, resource: R) -> Result<Option<R>, Error<R, Self>> { | 21 | pub fn check<R: std::fmt::Debug>(&self, resource: R) -> Result<Option<R>, Error<R>> { |
| 22 | match self { | 22 | match self { |
| 23 | Permission::Allow => Ok(Some(resource)), | 23 | Permission::Allow => Ok(Some(resource)), |
| 24 | Permission::Deny => Ok(None), | 24 | Permission::Deny => Ok(None), |