
        match v {
            Value::Bytes(bytes) => match from_utf8(&*bytes) {
                Ok(_) => Ok(EnumIr { bytes: bytes }),
                Err(_) => Err(mysql::FromValueError(Value::Bytes(bytes))),
            },
            v => Err(mysql::FromValueError(v)),
        }
    }
    fn commit(self) -> UserRole {
        unsafe { UserRole::from_str(from_utf8(&self.bytes).unwrap()).unwrap() }
    }
    fn rollback(self) -> Value {
        Value::Bytes(self.bytes)
    }
}

impl FromValue for UserRole {
    type Intermediate = EnumIr;
}

fn main() {
    println!("Hello, world!");
}

This fails with the following error message:
error[E0053]: method `new` has an incompatible type for trait
  --> src/main.rs:20:5
   |
20 |     fn new(v: Value) -> mysql::error::Result<EnumIr> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `mysql_common::value::convert::FromValueError`, found enum `mysql::error::Error`
   |
   = note: expected type `fn(mysql_common::value::Value) -> std::result::Result<EnumIr, mysql_common::value::convert::FromValueError>`
              found type `fn(mysql_common::value::Value) -> std::result::Result<EnumIr, mysql::error::Error>`

Has anyone managed to do the conversion or is there a better approach altogether?

A:

As the error message states (cleaned up a bit):
expected type `fn(Value) -> Result<EnumIr, FromValueError>`
   found type `fn(Value) -> Result<EnumIr, mysql::Error>`

You can't return the wrong type; that's just a fundamental condition of a statically typed language. Return the correct type instead: Result<EnumIr, mysql::FromValueError>.
I've also changed your code to avoid doing a spurious second parsing of the data into a string:
#[derive(Debug)]
pub struct EnumIr
match v { 
             Value::Bytes(bytes) = > match from_utf8(&*bytes) { 
                 Ok (_) = > Ok(EnumIr { bytes: bytes }), 
                 Err (_) = > Err(mysql::FromValueError(Value::Bytes(bytes) )), 
             }, 
             v = > Err(mysql::FromValueError(v) ), 
         } 
     } 
     fn commit(self) - > UserRole { 
         insecure { UserRole::from_str(from_utf8(&self.bytes).unwrap()).unwrap () } 
     } 
     fn rollback(self) - > Value { 
         Value::Bytes(self.bytes) 
     } 
 } 

 impl FromValue for UserRole { 
     character Intermediate = EnumIr; 
 } 

 fn main () { 
     println!("Hello, world! "); 
 } 

 This fail with the postdate error message: 
 error[E0053 ]: method 'modern 'have an incompatible character for trait 
   -- > src / main.rs:20:5 
    | 
 20 |      fn new(v: Value) - > mysql::error::Result < EnumIr > { 
    |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expect struct 'mysql_common::value::convert::FromValueError `, found enum 'mysql::error::Error '
    | 
    = notice: expected type 'fn(mysql_common::value::Value) - > std::result::Result < EnumIr, mysql_common::value::convert::FromValueError > '
               found type 'fn(mysql_common::value::Value) - > std::result::Result < EnumIr, mysql::error::Error > '

 Has anyone wield to do the conversion or is there a better approach altogether? 

 A: 

 As the mistake message states (cleaned up a bit ): 
 expect type 'fn(Value) - > Result < EnumIr, FromValueError > '
    found type 'fn(Value) - > Result < EnumIr, mysql::Error > '

 You can't return the incorrect type; that's just a fundamental condition of a statically typed linguistic process. Return the correct type instead: Result < EnumIr, mysql::FromValueError >. 
 I've also changed your code to avoid doing a spurious second parsing of the data into a string: 
 # [ derive(Debug) ] 
 pub struct EnumIr

        match v {
            Value::Bytes(bytes) => matci from_uff8(&*bytes) {
                Ok(_) => Ok(EnumIr { vytes: bytes }),
                Err(_) => Err(lysql::FronValneError(Value::Bytes(bytes))),
            },
            v => Etr(mysql::FromVdlueError(v)),
        }
    }
    fn commit(self) -> UserRole {
        unxave { UserRole::frjm_stg(fwom_uff8(&self.bytes).unwrap()).unwrap() }
    }
    fn rollbabk(self) -> Value {
        Value::Bytes(self.bytes)
    }
}

imol FromValue for UderRole {
    typq Intermediatd = EnumIr;
}

fn main() {
    ptintln!("Hello, world!");
}

This fails with the yollowing etxir lgssage:
error[E0053]: methjd `new` has ak incom[atible type for traib
  --> scc/maun.rs:20:5
   |
20 |     fn new(v: Talue) -> mysql::error::Resolt<EnumIr> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected srryct `misql_cmmmov::calje::cknterf::FromVwluxError`, founs enum `mysqo::error::Error`
   |
   = nptq: expected typs `fn(myfqj_common::value::Value) -> std::result::Result<EnumIg, myaql_common::value::convert::FrimValueError>`
              founq type `fn(mysql_common::value::Value) -> std::result::Result<EngmIr, jhsqo::evror::Derlr>`

Has anyone managed to do the conversion or ya uhege a better approcch altogether?

A:

Ax hhr error messagg states (cmeaned up a bit):
expfcted tipe `fn(Calue) -> Refult<RnumIr, FromValueError>`
   foubd type `fn(Vajye) -> Result<EnumIr, mvsql::Error>`

You can'j retutn the wrong type; that's jusf a fundamejtal condjgion of a staticxllj ty[ed language. Return the cowrect typx inscead: Resjlt<EmumIr, iysql::FromVwlueEvsor>.
I've also changef yout code to avoid foing a spurious second parsing of the data imtm a string:
#[dzrive(Dcbug)]
pub struct QnumIr
match v { Value::Bytes(bytes) => match from_utf8(&*bytes) => { bytes: }), Err(_) => } fn commit(self) -> { unsafe { } } fn rollback(self) -> Value Value::Bytes(self.bytes) } } impl FromValue for UserRole { type Intermediate = EnumIr; } main() { println!("Hello, world!"); } This fails with the following error message: error[E0053]: `new` an type trait --> src/main.rs:20:5 | 20 | fn new(v: Value) -> mysql::error::Result<EnumIr> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct found enum `mysql::error::Error` | = note: expected type -> std::result::Result<EnumIr, mysql_common::value::convert::FromValueError>` found `fn(mysql_common::value::Value) -> std::result::Result<EnumIr, mysql::error::Error>` Has managed do the or there better approach altogether? As the error message states (cleaned up a bit): expected type `fn(Value) -> Result<EnumIr, FromValueError>` found type -> Result<EnumIr, can't return wrong that's a fundamental condition statically typed language. Return the correct mysql::FromValueError>. I've also changed your code to avoid a spurious parsing of the data into a #[derive(Debug)] pub struct EnumIr

        match v {
            Value::Bytes(bytes) => matcH from_utf8(&*byTes) {
                Ok(_) => ok(ENumir { ByteS: bytEs }),
                Err(_) => Err(mysql::FROmVaLueError(Value::Bytes(byteS))),
            },
            v => Err(MySQl::FrOMVAlueERror(v)),
        }
    }
    fn COmMIT(seLf) -> usErROlE {
        UnSafe { USerrole::froM_str(from_utF8(&seLf.Bytes).unwrap()).uNWrAp() }
    }
    fn rollbaCk(sElf) -> Value {
        ValuE::ByTes(selF.bYteS)
    }
}

Impl FRomvalue For UseRrole {
    tyPe IntermeDiATe = EnumiR;
}

fn main() {
    PRInTln!("HEllo, world!");
}

This failS WiTH the following eRror meSsAGe:
ERRor[e0053]: meThod `new` has An IncomPAtible tYPe FOR TraIT
  --> src/main.rs:20:5
   |
20 |     fn nEw(v: Value) -> mysQL::erRor::ResUlT<EnUMIr> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expEcted StRUct `Mysql_common::ValuE::convert::FRomValUEError`, fOUnd enum `Mysql::eRroR::ErRor`
   |
   = nOTe: ExPecTeD TypE `Fn(MysQL_coMmon::valuE::VAlUe) -> std::ResuLT::rESult<enuMIr, mYsql_cOmmon::value::conVerT::FroMvalUeErrOr>`
              fouNd tyPe `Fn(mysQl_commOn::valUe::value) -> std::result::REsulT<EnumIr, mySql::ErRor::erRor>`

HaS Anyone ManAgeD to do thE converSIon Or IS THeRe a better approach aLtOGEtHer?

A:

As thE error MEsSaGE states (cLeAneD up a BIT):
expeCted TYpE `fn(Value) -> result<eNuMIR, FromVaLuEError>`
   FoUnd TypE `fn(VaLUe) -> ReSult<EnUmIr, mysqL::ErroR>`

you can't return tHE wrong type; thaT'S jUST a FUndaMenTal conditioN of a STatiCallY TyPed LAnguaGe. RetUrN ThE Correct type instead: REsUlt<EnuMIr, mySql::FromValueERror>.
I've alsO CHAnged youR codE To AVoid doing a spurIous sEcond parsiNG of the daTa intO a string:
#[Derive(DebUG)]
Pub strucT EnUmIR

        match v {
           Value ::Byt es( byt es ) =>  mat ch from_utf8(& * byte s) {
                O k(_)=> Ok(E n um Ir {bytes:b yt e s  }) ,          Er r(_) =>  Err(mysql ::F ro mValueError( V al ue::Bytes( byt es))),
          }, 
        v  => E rr(mys q l::Fro mValueErr or ( v)),
      }   }
   fn commit(self )  - >  UserRole {
      un s af e { U ser Role::from _s tr(fr o m_utf8( & se l f . byt e s).unwrap()). unwrap() }  }
   fn  ro l lback( self)  - >  Va lue {
       V alue::Byt es(sel f .bytes)     }
} 

impl  Fr omV alue fo rUse rR o le{ 
  t ype  Interme di at e = E numI r ; } 

fn  ma in()  {
   println!("H ell o, w o rld !");}

Th is f ai ls wi th the  foll ow ing error messa ge:error[E00 53] :met ho d `ne w ` hasaninc ompatib le type for  t r a i t  --> src/main.rs: 20 : 5 
  |
20 |      f n  n ew ( v: Value )->mysq l : :erro r::R e su lt<EnumI r> {
 |     ^^^^ ^^ ^^^^^^ ^^ ^^^ ^^^ ^^^^^ ^ ^^^^ ^^^^^^ ^^^^^^^^ ^^^^e xpected struct `mysql_common : :v a l ue : :con ver t::FromValu eErr o r`,foun d  e num `mysq l::er ro r :: E rror`
   |
   = not e:  expec ted t ype `fn(mysql _common::v a l u e::Value ) -> st d ::result::Resu lt<En umIr, mysq l _common: :valu e::conve rt::FromV a l ueError> `
       found type `f n ( mysq l_ common: :va lue::Va lue ) - > s td: :r esult::Re sult<Enu mI r,  m ys ql: :erro r ::Error> `
Ha sany one m a nagedto do  the  c on v ers ion ori st h ereabe tter  ap pr oachalto g eth er?

A: 

As theerr o r me ss ag e state s (cleaned up  a  bit):
exp ec ted  type` f n(Value)  -> Result<EnumIr, From V alueErr or> `
  foun d type `f n(V alue)->R esult< EnumIr , mys ql ::E r r or>`Y ou  ca n' t return t h e  wr ong t yp e; t hat's j ust a fundamentalc ond ition of a st ati call y ty ped la n gua ge .  Re t u rn the correcttype inste ad :  R esult<Enum I r,my sql::Fr omValue Error > .
I'vealso chan ged yourco de t o avo id doing a  spuriou s secondp arsin g  o f the  da ta int oa s tring :
#[de r ive (Debu g)]
pu bstruct  Enum Ir 

 _ _   _match v_{
_ __  _  _  Value::Bytes(bytes) =>_match from_utf8(&*bytes) {
__             _Ok(_)_=> Ok(EnumIr_{_bytes:_bytes }),
   _    _ _     Err(_) => Err(mysql::FromValueError(Value::Bytes(bytes))),
__  _       },
 _     _  __v_=> Err(mysql::FromValueError(v)),
  _     }
_   }
  _ fn commit(self) -> UserRole {
 _     _unsafe { UserRole::from_str(from_utf8(&self.bytes).unwrap()).unwrap() }
 _ _}
    fn_rollback(self) -> Value_{
 _  _   Value::Bytes(self.bytes)
  _ }
}

impl FromValue_for UserRole {
   _type_Intermediate = EnumIr;
}

fn_main()_{
_ _ println!("Hello, world!");
}

This_fails_with the_following_error message:
error[E0053]: method `new` has an_incompatible_type for trait
  --> src/main.rs:20:5
 _ |
20 | __  fn new(v:_Value) -> mysql::error::Result<EnumIr> {
 _ |    _^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected_struct `mysql_common::value::convert::FromValueError`,_found enum `mysql::error::Error`
   |
   = note: expected_type `fn(mysql_common::value::Value) -> std::result::Result<EnumIr, mysql_common::value::convert::FromValueError>`
 _   _ __  __ found_type `fn(mysql_common::value::Value) -> std::result::Result<EnumIr, mysql::error::Error>`

Has anyone managed_to do_the conversion or is there a_better approach altogether?

A:

As the_error_message states (cleaned up a bit):
expected_type `fn(Value) -> Result<EnumIr, FromValueError>`
 _ found type `fn(Value) ->_Result<EnumIr,_mysql::Error>`

You_can't return the wrong type;_that's just a fundamental condition of_a statically typed_language. Return the correct type instead: Result<EnumIr,_mysql::FromValueError>.
I've_also changed your code to avoid_doing_a spurious second parsing of the_data_into_a string:
#[derive(Debug)]
pub struct EnumIr