We have a custom Codec. For my Decoder
I have a state buffer with a bunch of variables. An employee got an error while trying to use it in a new service the other day, and we tracked it down to the struct containing a writer: Option<Box<dyn Write>>
. I don't recall the error, but it was something that implied it was crossing a future's bounds.
I hadn't noticed until earlier, but I noticed that our Codec
indeed is !Send
and !Sync
, which makes sense. But what I'm not entirely sure about is how to make it Send
and Sync
again.
Just to make sure it was that member I tried simply commenting it out, and fixing the few errors that followed (minimal changes). This caused our Codec
to become Send
and Sync
again.
So then I figured that I just need to slap an Arc<Mutex<...>> on it and I'd be set.
Well, needless to say (because I'm asking) that didn't help.
If my Decoder
contains a Option<Box<dyn Write>>
-- how would I go about regaining Send
and Sync
(assuming that this member is the one causing it to lose them).