From a6db5a346d4a07d92fa51194487edcef883e70b9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 28 Apr 2021 18:02:17 +0100 Subject: [PATCH] specs: Introduce samescope.table.toml And the supporting Rust code. Signed-off-by: Ian Jackson --- specs/samescope.table.toml | 6 ++++++ src/spec.rs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 specs/samescope.table.toml diff --git a/specs/samescope.table.toml b/specs/samescope.table.toml new file mode 100644 index 00000000..3b7e0904 --- /dev/null +++ b/specs/samescope.table.toml @@ -0,0 +1,6 @@ +# Copyright 2020-2021 Ian Jackson and contributors to Otter +# SPDX-License-Identifier: AGPL-3.0-or-later +# There is NO WARRANTY. + +[[players]] +same_scope = true diff --git a/src/spec.rs b/src/spec.rs index 83c84c2c..1c50cb9d 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -101,6 +101,7 @@ pub enum TablePlayerSpec { Account(AccountName), AccountGlob(String), Local(String), + SameScope, AllLocal, } @@ -358,7 +359,7 @@ pub mod imp { } impl TablePlayerSpec { - pub fn account_glob(&self, _instance_name: &InstanceName) -> String { + pub fn account_glob(&self, instance_name: &InstanceName) -> String { fn scope_glob(scope: AccountScope) -> String { let mut out = "".to_string(); scope.display_name(&[""], |s| Ok::<_,Void>(out += s)).unwrap(); @@ -368,6 +369,7 @@ pub mod imp { match self { TPS::Account(account) => account.to_string(), TPS::AccountGlob(s) => s.clone(), + TPS::SameScope => scope_glob(instance_name.account.scope.clone()), TPS::Local(user) => scope_glob(AS::Unix { user: user.clone() }), TPS::AllLocal => { // abuse that usernames are not encoded -- 2.30.2