Giter VIP home page Giter VIP logo

Comments (5)

Genarito avatar Genarito commented on June 16, 2024 1

Hi @K4rakara!

Thanks for your report! I'm going to fix it during the next week :)

from gura.

Genarito avatar Genarito commented on June 16, 2024 1

I am pleased to announce that I have now released version 0.1.4 of the crate 🥳 I noticed that it was throwing an error when the HashMap key was numeric instead of String. With the new version of Serde Gura you can now use the example above but with usize, isize, u8, u32, i32, i32, u64, i64, etc as the key type!

// ...
#[derive(Debug, Deserialize, Serialize, PartialEq)]
struct Shards {
    resumable_shards: HashMap<usize, Values>, // NEW: numeric key!
}
// ...

Thanks for reporting and using Gura! I will close the issue, feel free to reopen it if you consider that the problem is still not solved.

Regards! 😄

from gura.

Genarito avatar Genarito commented on June 16, 2024

Excuse me @K4rakara , could you provide the code you're trying, please? So I can replicate exactly

from gura.

Genarito avatar Genarito commented on June 16, 2024

Hi! I've been trying but I couldn't replicate the error. The following code serializes/deserializes correctly:

use std::collections::HashMap;
use serde_derive::{Deserialize, Serialize};
use serde_gura::Result;

#[derive(Debug, Deserialize, Serialize, PartialEq)]
struct Values {
    session_id: String,
	sequence: u32
}

#[derive(Debug, Deserialize, Serialize, PartialEq)]
struct Shards {
    resumable_shards: HashMap<String, Values>,
}


fn main() -> Result<()> {
    let gura_string = r#"resumable_shards:
    0:
        session_id: "xxxx"
        sequence: 2"#;

    let shards: Shards = serde_gura::from_str(gura_string)?;
	println!("{:?}", shards);
	println!("{}", serde_gura::to_string(&shards).unwrap());

    Ok(())
}

Anyway, I would like to know how the structure you are deserializing is, since the error line indicates that there is an Error variant that I didn't consider in the implementation of the Display trait for serde_gura::Error.

from gura.

K4rakara avatar K4rakara commented on June 16, 2024

I'll see if I can repo, though I've changed my code a fair deal since then, so I'll have to test it in an isolated example.

from gura.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.