NLnetLabs / domain

A DNS library for Rust.
https://nlnetlabs.nl/projects/domain/about/
BSD 3-Clause "New" or "Revised" License
364 stars 63 forks source link

mysql-zone ReadableZone::query_async cannot be shared between threads safely #443

Open moqle opened 3 hours ago

moqle commented 3 hours ago

Box::pin(fut) | ^^^^^^^^^^^^^ dyn Future<Output = std::result::Result<Vec<MySqlRow>, sqlx::Error>> + std::marker::Send cannot be shared between threads safely

How can I fixed it?

ximon18 commented 3 hours ago

Hi @moqle,

Thankyou for trying out the domain crate, especially the unstable Zone feature and the MySQL example!

https://docs.rs/domain/latest/domain/zonetree/trait.ReadableZone.html#method.query_async shows that the function signature includes both Send and Sync:

fn query_async(
    &self,
    qname: Name<Bytes>,
    qtype: Rtype,
) -> Pin<Box<dyn Future<Output = Result<Answer, OutOfZone>> + Send + Sync>>

Your code fragment lacks the Sync bound. Perhaps you need to add it?

Ximon