uuid-rs / uuid

Generate and parse UUIDs.

Home Page:https://www.crates.io/crates/uuid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

the trait Deserialize is not implemented for `Uuid`

andinus opened this issue · comments

I'm not sure what caused this, I did not commit Cargo.lock so I'm unable to get back to earlier state. I'm getting these errors when building a project:

28   |     pub id: Uuid,                                                                                                                                                                                    
     |             ^^^^ the trait `Deserialize<'_>` is not implemented for `Uuid`                                                                                                                           
     |                                                                                                                                                                                                      
     = help: the following other types implement trait `Deserialize<'de>`:                                                                                                                                  
               <bool as Deserialize<'de>>                                                                                                                                                                   
               <char as Deserialize<'de>>                                                                                                                                                                   
               <isize as Deserialize<'de>>                                                                                                                                                                  
               <i8 as Deserialize<'de>>                                                                                                                                                                     
               <i16 as Deserialize<'de>>                                                                                                                                                                    
               <i32 as Deserialize<'de>>                                                                                                                                                                    
               <i64 as Deserialize<'de>>                                                                                                                                                                    
               <i128 as Deserialize<'de>>                                                                                                                                                                   
             and 196 others                                                                                                                                                                                 
note: required by a bound in `next_element`                                                                                                                                                                 
    --> /home/andinus/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.196/src/de/mod.rs:1726:12                                                                                  
     |                                                                                                                                                                                                      
1724 |     fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>                                                                                                                                  
     |        ------------ required by a bound in this associated function                                                                                                                                  
1725 |     where                                                                                                                                                                                            
1726 |         T: Deserialize<'de>,                                                                                                                                                                         
     |            ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element`     

Cargo.toml

[dependencies]                                                                                                                                                                                              
serde = { version = "1.0", features = ["derive"] }                                                                                                                                                          
serde_json = "1.0"                                                                                                                                                                                                                                                                                                                                                                       
tower-sessions-sqlx-store = { version = "0.10", features = ["postgres"]}                                                                                                                                    
sqlx = { version = "0.7", features = ["runtime-tokio", "postgres", "uuid", "ipnetwork", "json", "macros", "time"] }                                                                                                                                                                                                                                                                               
uuid = "1.7"                                                                                                                                                                                                
...                         

Hi @andinus 👋

If you add the serde feature of uuid to your Cargo.toml that should get you back to good:

uuid = { version = "1.7", features = ["serde"] }

Chances are another dependency somewhere in your dependency tree also depended on uuid and was bringing in this feature already, but isn't anymore.