I am using https://docs.rs/mysql/19.0.1/mysql/ to fetch some rows from a mySQL-Database. I assign them to a struct like this:
use mysql::*;
use mysql::prelude::*;
use serde::Serialize;
#[derive(Debug, PartialEq, Eq, Serialize)]
pub struct Policy {
sub: Option<mysql::Binary>,
contents: Option<String>,
}
pub fn list_policies() -> Result<Vec<Policy>> {
let url = "";
let pool = Pool::new(url)?;
let mut connection = pool.get_conn()?;
let policies: Vec<Policy> = connection.query_map("SELECT sub, contents FROM policy", |(sub, contents)| {
Policy { sub, contents }
},)?;
Ok(policies)
}
Problem is that some of my rows are stored in mysql binary
format (uuid binary(16)
for example.) I discovered the mysql::Binary
but when I want to use it in my struct, I get the following error:
error[E0369]: binary operation `==` cannot be applied to type `std::option::Option<mysql::Binary>`
--> src/database/mod.rs:7:2
|
7 | sub: Option<mysql::Binary>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
and a few similar ones with "Eq" etc.
My question is: How can I fetch binary-columns with the rust mysql-package? I can't find anything using the provided documentation. Any example would be great.