chiark / gitweb /
specs: Introduce samescope.table.toml
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 28 Apr 2021 17:02:17 +0000 (18:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 28 Apr 2021 17:02:17 +0000 (18:02 +0100)
And the supporting Rust code.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
specs/samescope.table.toml [new file with mode: 0644]
src/spec.rs

diff --git a/specs/samescope.table.toml b/specs/samescope.table.toml
new file mode 100644 (file)
index 0000000..3b7e090
--- /dev/null
@@ -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
index 83c84c2cc59bdfa4902cab414e8a3916e3c041e1..1c50cb9d3be60e0c76a8dcd247a988132cc297f3 100644 (file)
@@ -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