From a8df2b6a6fa0179eeef6a41570db6d5d2eecafa3 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Tue, 7 Mar 2023 09:55:35 +0000 Subject: [PATCH] Allow any `Value` in arguments to RPC `use` method --- src/net/rpc.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/net/rpc.rs b/src/net/rpc.rs index 1b13c97f..c0a62298 100644 --- a/src/net/rpc.rs +++ b/src/net/rpc.rs @@ -235,7 +235,7 @@ impl Rpc { }, // Switch to a specific namespace and database "use" => match params.needs_two() { - Ok((Value::Strand(ns), Value::Strand(db))) => rpc.write().await.yuse(ns, db).await, + Ok((ns, db)) => rpc.write().await.yuse(ns, db).await, _ => return res::failure(id, Failure::INVALID_PARAMS).send(out, chn).await, }, // Signup to a specific authentication scope @@ -367,9 +367,13 @@ impl Rpc { Ok(Value::None) } - async fn yuse(&mut self, ns: Strand, db: Strand) -> Result { - self.session.ns = Some(ns.0); - self.session.db = Some(db.0); + async fn yuse(&mut self, ns: Value, db: Value) -> Result { + if let Value::Strand(ns) = ns { + self.session.ns = Some(ns.0); + } + if let Value::Strand(db) = db { + self.session.db = Some(db.0); + } Ok(Value::None) }