Skip to content

Commit 32b88a2

Browse files
junderwrustyrussell
authored andcommitted
Fix: Remove Sync requirements on Futures returned in the Rust plugin library.
See: bitcoindevkit/bdk#1047 (comment) In general, futures produced by most libraries in the ecosystem of Rust, and bounds placed on users of famous runtimes like tokio and its spawn method all lack Sync requirements. Because of this, anyone who creates a callback using any sort of library that returns a non-Sync future (which most libraries fit this description) inside of it will get some cryptic error messages (async error messages still leave a lot to be desired). Removing these Sync requirements will make the library more useful.
1 parent 29fea55 commit 32b88a2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

plugins/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ where
104104
impl<S, I, O> Builder<S, I, O>
105105
where
106106
O: Send + AsyncWrite + Unpin + 'static,
107-
S: Clone + Sync + Send + Clone + 'static,
107+
S: Clone + Sync + Send + 'static,
108108
I: AsyncRead + Send + Unpin + 'static,
109109
{
110110
pub fn new(input: I, output: O) -> Self {
@@ -146,7 +146,7 @@ where
146146
where
147147
C: Send + Sync + 'static,
148148
C: Fn(Plugin<S>, Request) -> F + 'static,
149-
F: Future<Output = Result<(), Error>> + Send + Sync + 'static,
149+
F: Future<Output = Result<(), Error>> + Send + 'static,
150150
{
151151
self.subscriptions.insert(
152152
topic.to_string(),
@@ -162,7 +162,7 @@ where
162162
where
163163
C: Send + Sync + 'static,
164164
C: Fn(Plugin<S>, Request) -> F + 'static,
165-
F: Future<Output = Response> + Send + Sync + 'static,
165+
F: Future<Output = Response> + Send + 'static,
166166
{
167167
self.hooks.insert(
168168
hookname.to_string(),
@@ -179,7 +179,7 @@ where
179179
where
180180
C: Send + Sync + 'static,
181181
C: Fn(Plugin<S>, Request) -> F + 'static,
182-
F: Future<Output = Response> + Send + Sync + 'static,
182+
F: Future<Output = Response> + Send + 'static,
183183
{
184184
self.rpcmethods.insert(
185185
name.to_string(),
@@ -504,7 +504,7 @@ where
504504

505505
impl<S> PluginDriver<S>
506506
where
507-
S: Send + Clone + Sync,
507+
S: Send + Clone,
508508
{
509509
/// Run the plugin until we get a shutdown command.
510510
async fn run<I, O>(

0 commit comments

Comments
 (0)