uuid-rs / uuid

Generate and parse UUIDs.
https://www.crates.io/crates/uuid
Other
1.01k stars 192 forks source link

the trait Deserialize is not implemented for `Uuid` #731

Closed andinus closed 9 months ago

andinus commented 9 months ago

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"                                                                                                                                                                                                
...                         
KodrAus commented 9 months ago

Hi @andinus :wave:

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.

andinus commented 9 months ago

Thank you that fixed it. My bad, I didn't realize it could be this, I was fiddling with other things.

Also, thank you for uuid :)

Ashley Mannix @ 2024-01-28 13:54 -08:

Hi @andinus :wave:

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.