From 94040ae566c907d653c586bd88d3cf0984290013 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 30 Jan 2023 17:29:25 +0100 Subject: [PATCH] More ergonomic guard api --- syndicate-server/src/main.rs | 2 +- syndicate/src/actor.rs | 3 ++- syndicate/src/relay.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/syndicate-server/src/main.rs b/syndicate-server/src/main.rs index 73a17e1..2a5ffeb 100644 --- a/syndicate-server/src/main.rs +++ b/syndicate-server/src/main.rs @@ -108,7 +108,7 @@ async fn main() -> ActorResult { })); } - let gatekeeper = Cap::guard(Arc::clone(Language::arc()), t.create( + let gatekeeper = Cap::guard(Language::arc(), t.create( syndicate::entity(Arc::clone(&server_config_ds)) .on_asserted(gatekeeper::handle_assertion))); diff --git a/syndicate/src/actor.rs b/syndicate/src/actor.rs index 81b0933..6f9ae92 100644 --- a/syndicate/src/actor.rs +++ b/syndicate/src/actor.rs @@ -2246,13 +2246,14 @@ impl Cap { /// `Cap` automatically decodes presented `AnyValue`s into /// instances of `M`. pub fn guard( - literals: Arc, + literals: &Arc, underlying: Arc>, ) -> Arc where M: for<'a> Unparse<&'a L, AnyValue>, M: for<'a> Parse<&'a L, AnyValue>, { + let literals = Arc::clone(literals); Self::new(&Arc::new(Ref { mailbox: Arc::clone(&underlying.mailbox), facet_id: underlying.facet_id, diff --git a/syndicate/src/relay.rs b/syndicate/src/relay.rs index ae2ea31..42e9ca0 100644 --- a/syndicate/src/relay.rs +++ b/syndicate/src/relay.rs @@ -761,7 +761,7 @@ impl Entity for RelayEntity { fn sync(&mut self, t: &mut Activation, peer: Arc>) -> ActorResult { self.relay_ref.lock().as_mut().expect("initialized") .send_event(t, self.oid.clone(), P::Event::Sync(Box::new(P::Sync { - peer: Cap::guard(Arc::new(()), peer) + peer: Cap::guard(&Arc::new(()), peer) }))) } }