From 118c2b60275687fd46a90f02d77eca2c928856b6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 26 Jul 2020 23:28:41 +0100 Subject: [PATCH] get_scope nfc --- src/cmdlistener.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index 452b24a5..cbc2b2e4 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -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 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); -- 2.30.2