-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to deserialize #139
Comments
@leontoeides Thank you for reporting this issue. The error message is unclear, and a first improvement has just been merged #140. And secondly, instead of causing the program to crash, a proper error will be returned #141. Now related to your issue, in my opinion, you are storing data in your database and evolving your models without splitting them into different versions. This means that you are trying to query a model that no longer has the same fields or the same types of fields. This can often happen when you are developing an application. If you delete your database and re-run your code, does the problem still occur? |
I'll try to provide more details, eventually, when I can. In my case, the struct definition has not changed. I was working on a brand new blank database, and I was reading back all records I'd just written in the same execution. The struct I'm using is pretty hefty and I'd imagine it'd be a challenging case for a serializer/deserializer. I am successfully using this (almost) same struct with |
@leontoeides Ok, so under the hood,
If the error persists and you find no solution, you can always use |
Both
I remember this one. I recall playing with musli::storage looks interesting but there's no Also, Just some feedback - the struct for postcard was hard to find because it didn't make it into the docs. It seems like there's a way to document featured-gated items, though. This was tricky to find: I implemented a codec using
|
Thanks to pointing it, I have opened an issue here vincent-herlemont/native_model#70. @leontoeides It might be a good idea to add @leontoeides Is everything good for you on this topic? If so, I will let you close the issue. |
Hi. I'm also experiencing this kind of issues in my project. @leontoeides, could you specify what exactly you did to fix the issue on your end? Thanks. |
Hello @LunaeSomnia, it looks like the default serializer
pub struct RmpSerde;
impl<T: serde::Serialize> native_model::Encode<T> for RmpSerde {
type Error = rmp_serde::encode::Error;
fn encode(obj: &T) -> Result<Vec<u8>, Self::Error> {
rmp_serde::encode::to_vec(obj)
}
}
impl<T: for<'de> serde::Deserialize<'de>> native_model::Decode<T> for RmpSerde {
type Error = rmp_serde::decode::Error;
fn decode(data: Vec<u8>) -> Result<T, Self::Error> {
rmp_serde::decode::from_slice(&data)
}
}
#[native_model(id = 1, version = 1, with = RmpSerde)]
struct My Struct {
pub string: String,
} @vincent-herlemont Yes I will try to make a PR sometime this weekend |
Hey @leontoeides, I just implemented your instructions & ended up working. The serialization made by Thank you very much for your time. |
With the merging of this PR #141, the database will no longer cause a panic related to deserialization. Each query returns a result. This will be available in version 0.7.0 of |
Good morning,
Thank you for this crate! It's exactly what I've been looking for. The way you've handled secondary indicies is perfect 👌and very powerful.
Unfortunately when I use the crate I get this error:
This happens when I try to scan the entire database.
I might be able to provide more details later, I just wanted to make sure I opened this issue before I forgot
The text was updated successfully, but these errors were encountered: