MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from_str

Method from_str

atomic-identity/src/delegation.rs:164–179  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 2

as_strMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected