From: Ian Jackson Date: Wed, 28 Apr 2021 17:02:17 +0000 (+0100) Subject: specs: Introduce samescope.table.toml X-Git-Tag: otter-0.6.0~515 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a6db5a346d4a07d92fa51194487edcef883e70b9;p=otter.git specs: Introduce samescope.table.toml And the supporting Rust code. Signed-off-by: Ian Jackson --- 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