Skip to content
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

FR: Better ergonomics in structs? #159

Open
max-ishere opened this issue Mar 24, 2023 · 3 comments
Open

FR: Better ergonomics in structs? #159

max-ishere opened this issue Mar 24, 2023 · 3 comments

Comments

@max-ishere
Copy link

Here is what I expected an entry to look like. Imo it's better.

Entry {
    pub title: String,
    pub username: String,
    pub password: String,
    // ...
}

My expectation comes seeing it this way in a GUI. Another reason is that renaming a string key is not a good idea.

This would require adding custom serde code tho..

@max-ishere
Copy link
Author

Just to be clear I wanted to get some feedback to know if this is something I should try to implement.

@sseemayer
Copy link
Owner

sseemayer commented May 31, 2023

Sorry for the late reply. I agree from a usability perspective.

Right now, the crate more closely follows the format of the XML file that is inside of every KeePass database, where there can be arbitrary key-value pairs called fields, and username, title and password are just special cases. Handling fields as a HashMap<String, Value> simplifies the parsing and writing code.

We provide the Entry::get_username and other convenience functions to retrieve the most important field values.

I'm not sure if you were referring to our feature-gated serde support when you were talking about custom serde code. I would be willing to accept a PR that has a custom impl Serialize for Entry which generates more intuitive JSON output.

@max-ishere
Copy link
Author

Hi, thanks for the reply. The custom serde code is the implementation of deserialize that puts specific xml keys into a struct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants