From 6da4613578f1effb371f4f3dd6605c1dff16b0b7 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Mon, 29 Nov 2021 14:18:30 +0100 Subject: rework SyncProxy to use globally available channels the SyncProxy is now a globally available OnceCell that transparently offers a struct with methods to send syncmessages and rpccalls. This allows me to get rid of the globally passed around syncproxy var. The Syncable trait provides default implementations that access this global so the library user usually does not need to use it directly. Further the Syncable trait now provides default implementations for it's methods and only a const for the CLASS name must be set. It isn't very idiomatic rust and takes away some freedom from the library user but i think that it's an overall nicer solution and simplifies the code big time. --- src/message/signalproxy/objects/aliasmanager.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/message/signalproxy/objects/aliasmanager.rs') diff --git a/src/message/signalproxy/objects/aliasmanager.rs b/src/message/signalproxy/objects/aliasmanager.rs index 61a68ce..3d8133a 100644 --- a/src/message/signalproxy/objects/aliasmanager.rs +++ b/src/message/signalproxy/objects/aliasmanager.rs @@ -35,7 +35,7 @@ impl StatefulSyncableClient for AliasManager {} #[cfg(feature = "server")] impl StatefulSyncableServer for AliasManager { - fn sync_custom(&mut self, _session: impl SyncProxy, mut msg: crate::message::SyncMessage) + fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) where Self: Sized, { @@ -49,14 +49,7 @@ impl StatefulSyncableServer for AliasManager { } impl Syncable for AliasManager { - fn send_sync( - &self, - session: impl SyncProxy, - function: &str, - params: crate::primitive::VariantList, - ) { - session.sync("AliasManager", None, function, params) - } + const CLASS: &'static str = "AliasManager"; } /// Alias -- cgit v1.2.3