Does anyone have a working implementation of mysql::FromRow? It might show me what I'm doing wrong. I've looked for one, but maybe I'm looking in the wrong place.
Cargo is giving me two different errors. The first version says
17 | fn from_row_opt(row: Row) -> Result<CallInfoRow, FromRowError> {
| ^^^^^^ ------------ help: remove this generic argument
| |
| expected 1 generic argument
|
but when I try to do as the help suggests, I get even more confusing errors:
17 | fn from_row_opt(row: Row) -> Result<CallInfoRow> {
| ^^^^^^^^^^^^^^^^^^^
| |
| expected struct `FromRowError`, found enum `Error`
| help: change the output type to match the trait: `std::result::Result<CallInfoRow, mysql::FromRowError>`
|
= note: expected signature `fn(mysql::Row) -> std::result::Result<_, mysql::FromRowError>`
found signature `fn(mysql::Row) -> std::result::Result<_, mysql::Error>`
error[E0308]: mismatched types
--> src/main.rs:17:34
|
17 | fn from_row_opt(row: Row) -> Result<CallInfoRow> {
| ------------ ^^^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected enum `std::result::Result<CallInfoRow, mysql::Error>`
found unit type `()`
Full main.rs in case it is helpful:
use mysql::*;
use mysql::prelude::*;
#[derive(Debug, PartialEq, Eq)]
struct CallInfoRow {
id: i32,
page: i32,
}
#[derive(Debug, PartialEq, Eq)]
struct CallInfoRowDupe {
id: i32,
page: i32,
}
impl FromRow for CallInfoRow {
fn from_row_opt(row: Row) -> Result<CallInfoRow> {
Ok(row);
}
}
fn main() {
println!("A message");
}