ritiek / rafy-rs

Rust library to download YouTube content and retrieve metadata
MIT License
50 stars 10 forks source link

Make rafy::Error usable with error-chain #6

Open alatiera opened 7 years ago

alatiera commented 7 years ago

I think error-chain needs the Error to impl std::marker::Send, Not sure though. Here is a compiler compain trying to add rafy::Error to error-chain:

error[E0277]: the trait bound `std::error::Error + 'static: std::marker::Send` is not satisfied           
  --> src/lib.rs:25:5     
   |                      
25 | /     error_chain! { 
26 | |         foreign_links {                       
27 | |             RafError(rafy::Error);            
28 | |             ReqError(reqwest::Error);         
...  |                    
31 | |         }          
32 | |     }              
   | |_____^ `std::error::Error + 'static` cannot be sent between threads safely                          
   |                      
   = help: the trait `std::marker::Send` is not implemented for `std::error::Error + 'static`             
   = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<std::error::Error + 'static>`
   = note: required because it appears within the type `std::boxed::Box<std::error::Error + 'static>`     
   = note: required because it appears within the type `rafy::Error`                                      
   = note: required because it appears within the type `errors::ErrorKind`                                
   = note: required because it appears within the type `errors::Error`                                    
   = note: this error originates in a macro outside of the current crate                   
alatiera commented 7 years ago

Turns out compiler is complaining about ? cause it couldnt find the Error type at the Erro-chain thing. And ? can be used with rafy!