Skip to content

Separate database format from HexView struct #58

Description

@glazari

Currently the save_database function uses the serialization of hex view struct directly to save to disk

    pub fn save_database(&self) -> Result<(), Box<dyn Error>> {
        let toml_string = toml::to_string_pretty(&self.hex_view)?;

And the hex view type looks something like this:

#[derive(Default, Serialize, Deserialize)]
pub struct HexView {
    #[serde(skip)]
    pub ascii_state: TableState,
    // blocks are ByteBlock structs -- ranges with different colors
    pub blocks: Vec<ColoredBlock>,
    pub bookmarks: Vec<usize>,
    #[serde(skip)]
    pub changed_bytes: HashMap<usize, String>,
...
}

There are 2 reason that I think it would be better to have a separate type for the "database"

  1. The on disk format is persistent across runs so it should be "extra stable"
  2. Sometimes the ideal format for in memory representation is not the same as the one for disk.

with them together we can accidentally break someone's database when trying to update some internal representation.
If they spent a while building up that database for that file, it might be frustrating.

If you think this is a good idea, I can implement it, just wanted to check what you think first

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions