chiark / gitweb /
get_scope nfc
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jul 2020 22:28:41 +0000 (23:28 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jul 2020 22:28:41 +0000 (23:28 +0100)
src/cmdlistener.rs

index 452b24a57fade7de3353f8b77799ade5aab1eb13..cbc2b2e4bc7c8f8a65b4d8afe3fe2acdbf2dff77 100644 (file)
@@ -50,6 +50,11 @@ impl CommandStream<'_> {
       self.write.flush()?;
     }
   }
+
+  #[throws(MgmtError)]
+  fn get_scope(&self) -> &ManagementScope {
+    self.scope.as_ref().ok_or(NoScope)?
+  }
 }
 
 impl From<serde_lexpr::Error> for MgmtError {
@@ -216,7 +221,7 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse {
       };
 
       let name = InstanceName {
-        scope : cs.scope.as_ref().ok_or(NoScope)?.clone(),
+        scope : cs.get_scope()?.clone(),
         scoped_name : name,
       };
 
@@ -238,7 +243,7 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse {
           authorise_scope(cs, &ManagementScope::Server)?;
         None
       } else {
-        let scope = cs.scope.as_ref().ok_or(NoScope)?;
+        let scope = cs.get_scope()?;
         Some(scope)
       };
       let mut games = list_games(scope);