MCPcopy Index your code
hub / github.com/endbasic/endbasic / parse_acl

Method parse_acl

client/src/cmds.rs:309–325  ·  view source on GitHub ↗

Parses a textual ACL specification and adds it to `add` or `remove.

(mut acl: String, add: &mut FileAcls, remove: &mut FileAcls)

Source from the content-addressed store, hash-verified

307impl ShareCommand {
308 /// Parses a textual ACL specification and adds it to `add` or `remove.
309 fn parse_acl(mut acl: String, add: &mut FileAcls, remove: &mut FileAcls) -> Result<(), String> {
310 let change = if acl.len() < 3 { String::new() } else { acl.split_off(acl.len() - 2) };
311 let username = acl; // For clarity after splitting off the ACL change request.
312 match (username, change.as_str()) {
313 (username, "+r") if !username.is_empty() => add.add_reader(username),
314 (username, "+R") if !username.is_empty() => add.add_reader(username),
315 (username, "-r") if !username.is_empty() => remove.add_reader(username),
316 (username, "-R") if !username.is_empty() => remove.add_reader(username),
317 (username, change) => {
318 return Err(format!(
319 "Invalid ACL '{}{}': must be of the form \"username+r\" or \"username-r\"",
320 username, change
321 ));
322 }
323 }
324 Ok(())
325 }
326
327 /// Checks if a file is publicly readable by inspecting a set of ACLs.
328 fn has_public_acl(acls: &FileAcls) -> bool {

Callers

nothing calls this directly

Calls 5

split_offMethod · 0.80
as_strMethod · 0.80
add_readerMethod · 0.80
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected