Global/Singleton variable without Send/Sync

I see, then the ”make PdfBuilder not Send” approach is the correct one. Sync probably doesn’t matter since you cannot even do anything with a &PdfBuilder.

The builder method accepting &self might actually not be problematic as long as everything’s single-threaded. Sure, the AsRef thing could be re-entreant, but as long as this .as_ref call doesn’t happen in a callback from the C code, or otherwise in the middle of multiple calls to the C library that must not be interleaved incorrectly, then there might not be any soundness problems after all.


I agree with @ZiCog’s solution if the intention is to actually use the PdfApplication from multiple threads.


Reading more of the crate, I hit another weirdness: The PdfOutput type has a lifetime, even though all methods of creating it can generically create a PdfOutput<'b> of any lifetime, including PdfOutput<'static>, and not related to anything else.