| 162 | type Err = String; |
| 163 | |
| 164 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 165 | match s.trim().to_lowercase().replace('-', "_").as_str() { |
| 166 | "read" => Ok(DelegationPermission::Read), |
| 167 | "record" => Ok(DelegationPermission::Record), |
| 168 | "push" => Ok(DelegationPermission::Push), |
| 169 | "pull" => Ok(DelegationPermission::Pull), |
| 170 | "manage_views" | "manage_stacks" => Ok(DelegationPermission::ManageViews), |
| 171 | "manage_tags" => Ok(DelegationPermission::ManageTags), |
| 172 | "admin" => Ok(DelegationPermission::Admin), |
| 173 | "full" => Ok(DelegationPermission::Full), |
| 174 | other => Err(format!( |
| 175 | "unknown permission '{other}' (expected one of: read, record, push, pull, \ |
| 176 | manage_views, manage_tags, admin, full)" |
| 177 | )), |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | /// The resource an authorization decision is being made about. |