ajrcarey / pdfium-render

A high-level idiomatic Rust wrapper around Pdfium, the C++ PDF library used by the Google Chromium project.
https://crates.io/crates/pdfium-render
Other
341 stars 52 forks source link

Question: How to use in another thread #161

Closed smw-wagnerma closed 2 weeks ago

smw-wagnerma commented 2 weeks ago

I can't figure out, how to use this library with the tokio runtime. I have to put this library in another thread (for a tauri app). But I always get these kind of errros: (dyn PdfiumLibraryBindings + 'static)` cannot be shared between threads safely the trait `Sync` is not implemented for `(dyn PdfiumLibraryBindings + 'static)`, which is required by `LazyLock<pdfium_render::prelude::Pdfium>: Sync` required for `Unique<(dyn PdfiumLibraryBindings + 'static)>` to implement `Sync` required for `LazyLock<pdfium_render::prelude::Pdfium>` to implement `Sync` shared static variables must have a type that implements `Sync In the thread_safe exampe, there seems no problems, but it uses the rayon runtime. With the tokio runtime it seems not possible. Is this right?

smw-wagnerma commented 2 weeks ago

Sorry, I figuerd it out, what was wrong... it was my fault, not your nice crate, sorry!

ajrcarey commented 2 weeks ago

Hi @smw-wagnerma , no problem, glad you were able to figure it out. What was the solution? I was going to ask if you had enabled the sync feature.