aboutsummaryrefslogtreecommitdiffstats
path: root/src/access/registry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/access/registry.rs')
-rw-r--r--src/access/registry.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/access/registry.rs b/src/access/registry.rs
index 5a58e1f..f0034ba 100644
--- a/src/access/registry.rs
+++ b/src/access/registry.rs
@@ -35,12 +35,12 @@ pub(crate) fn user_path(name: &str) -> Vec<String> {
/// Whether the swarm has a registry: until it has, every user a node lets in may do
/// everything but write protocol data (`docs/access.md`, A swarm without a registry).
-pub(crate) fn exists(doc: &impl Read) -> bool {
+pub(crate) fn exists(doc: &(impl Read + ?Sized)) -> bool {
matches!(view::keys_at(doc, &users_dir()), Ok(Some(_)))
}
/// The registered users' names, sorted.
-pub(crate) fn names(doc: &impl Read) -> Vec<String> {
+pub(crate) fn names(doc: &(impl Read + ?Sized)) -> Vec<String> {
let mut names = view::keys_at(doc, &users_dir())
.ok()
.flatten()
@@ -128,7 +128,7 @@ impl User {
}
/// The entry of user `name`, if it has one.
-pub(crate) fn user(doc: &impl Read, name: &str) -> Option<User> {
+pub(crate) fn user(doc: &(impl Read + ?Sized), name: &str) -> Option<User> {
let value = view::read_plain(doc, &user_path(name)).ok()??;
let mut user = value.is_object().then(|| User::from_json(&value))?;
// A damaged one revokes every token.
@@ -156,7 +156,7 @@ pub(crate) fn session_path(name: &str, session: &str) -> Vec<String> {
}
/// Whether user `name`'s session `session` was ended (`session_path`).
-pub(crate) fn session_ended(doc: &impl Read, name: &str, session: &str) -> bool {
+pub(crate) fn session_ended(doc: &(impl Read + ?Sized), name: &str, session: &str) -> bool {
view::read_path(doc, &session_path(name, session))
.ok()
.flatten()
@@ -164,7 +164,7 @@ pub(crate) fn session_ended(doc: &impl Read, name: &str, session: &str) -> bool
}
/// The users who may manage users: enabled, with `write` on `_continuum/users`.
-pub(crate) fn managers(doc: &impl Read) -> Vec<String> {
+pub(crate) fn managers(doc: &(impl Read + ?Sized)) -> Vec<String> {
names(doc)
.into_iter()
.filter(|name| caps_of(doc, name).allows(Right::Write, &users_dir()))
@@ -172,7 +172,7 @@ pub(crate) fn managers(doc: &impl Read) -> Vec<String> {
}
/// What user `name` may do: none if it isn't registered (or is disabled).
-pub(crate) fn caps_of(doc: &impl Read, name: &str) -> Caps {
+pub(crate) fn caps_of(doc: &(impl Read + ?Sized), name: &str) -> Caps {
user(doc, name).map(|user| user.caps()).unwrap_or_default()
}