You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the excellent work on bincode. I'm currently testing a simple memory based cache for a system I'm writing. In various places I'm calling serde::encode_to_vec and serde::decode_from_slice. I'm running into an error on decode_from_slice indicating CannotBorrowOwnedData. I briefly looked at the error, but haven't spent much time digging into it yet.
let test = MyStruct{name:"Test Value".to_owned(),};let value = MemCache::set_data::<MyStruct>(&cache_id,&test,5).await?;let model = MemCache::get_data::<MyStruct>(&cache_id).await?;
however, if I provide a struct that has other types, E.G. "Uuid and DateTime(chrono)", both of which have Serialize/Deserialize traits implement by their respective crates, I can successfully call encode_to_vec but decode_from_slice returns the aforementioned error.
let test2 = CustomerTest{id:Some(Uuid::new_v4()),email_address:Some("test@test_domain.io".to_owned()),is_active:Some(true),date_stamp:Some(Utc::now()),};let cache_id = Uuid::new_v4();let value = MemCache::set_data::<CustomerTest>(&cache_id,&test2,5).await?;let model = MemCache::get_data::<CustomerTest>(&cache_id).await?;
Testing it further, it appears that removing the Uuid type along with the DateTime<Utc> type results in a successful call to decode_from_slice. Again, it's possible to call encode_to_vec with all of the types listed above, but it does not appear to currently be possible to decode without raising the CannotBorrowOwnedData error.
Any advice on this would be welcomed. Thanks again for your efforts on bincode.
The text was updated successfully, but these errors were encountered:
Thanks for the excellent work on bincode. I'm currently testing a simple memory based cache for a system I'm writing. In various places I'm calling
serde::encode_to_vec
andserde::decode_from_slice
. I'm running into an error ondecode_from_slice
indicatingCannotBorrowOwnedData
. I briefly looked at the error, but haven't spent much time digging into it yet.I can do something simple like the following:
and then
where
set_data
and
get_data
however, if I provide a struct that has other types, E.G. "Uuid and DateTime(chrono)", both of which have Serialize/Deserialize traits implement by their respective crates, I can successfully call
encode_to_vec
butdecode_from_slice
returns the aforementioned error.E.G.:
Testing it further, it appears that removing the
Uuid
type along with theDateTime<Utc>
type results in a successful call todecode_from_slice
. Again, it's possible to callencode_to_vec
with all of the types listed above, but it does not appear to currently be possible to decode without raising theCannotBorrowOwnedData
error.Any advice on this would be welcomed. Thanks again for your efforts on bincode.
The text was updated successfully, but these errors were encountered: