{"id":26449381,"url":"https://github.com/grantshandy/disk-persist","last_synced_at":"2025-03-18T14:55:25.518Z","repository":{"id":45693940,"uuid":"514100976","full_name":"grantshandy/disk-persist","owner":"grantshandy","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-15T02:49:23.000Z","size":8,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T05:48:16.946Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grantshandy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-15T01:52:09.000Z","updated_at":"2023-02-07T18:50:54.000Z","dependencies_parsed_at":"2022-09-26T17:41:28.471Z","dependency_job_id":null,"html_url":"https://github.com/grantshandy/disk-persist","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantshandy%2Fdisk-persist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantshandy%2Fdisk-persist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantshandy%2Fdisk-persist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantshandy%2Fdisk-persist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grantshandy","download_url":"https://codeload.github.com/grantshandy/disk-persist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244246516,"owners_count":20422456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-18T14:55:24.755Z","updated_at":"2025-03-18T14:55:25.504Z","avatar_url":"https://github.com/grantshandy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Disk Persist\n\n[![CI](https://github.com/grantshandy/disk-persist/actions/workflows/rust.yml/badge.svg)](https://github.com/grantshandy/disk-persist/actions)\n[![](https://img.shields.io/crates/v/disk-persist.svg)](https://crates.io/crates/disk-persist)\n[![](https://img.shields.io/docsrs/disk-persist)](https://docs.rs/disk-persist)\n[![](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nA library that makes it very easy for your application to keep data inbetween executions. It can (very quickly) read and write any data structure that implements [serde](https://serde.rs/)'s `Serialize` and `Deserialize` to disk. It automatically saves the information to either the user's cache folder or any other path that you specify.\n\nDefault Location:\n\n|Platform | Value                               | Example                      |\n| ------- | ----------------------------------- | ---------------------------- |\n| Linux   | `$XDG_CACHE_HOME` or `$HOME`/.cache | /home/user/.cache           |\n| macOS   | `$HOME`/Library/Caches              | /Users/User/Library/Caches  |\n| Windows | `{FOLDERID_LocalAppData}`           | C:\\Users\\User\\AppData\\Local |\n\n## The Basics\n\nCreate our data:\n```rust\nuse serde::{Deserialize, Serialize};\n\n...\n\n#[derive(Serialize, Deserialize, Debug)]\nstruct Data {\n    name: String,\n    age: u8,\n}\n```\n\nWrite it to disk:\n```rust\nlet persist: DiskPersist\u003cData\u003e = DiskPersist::init(\"disk-persist-example\").unwrap();\n\nlet data = Data {\n    name: \"John Doe\".to_string(),\n    age: 45,\n};\n\npersist.write(\u0026data).unwrap();\n```\n\nThen read it at any time:\n```rust\nlet persist: DiskPersist\u003cData\u003e = DiskPersist::init(\"disk-persist-example\").unwrap();\n\nprintln!(\"{:#?}\", persist.read().unwrap());\n```\n\nOutputs:\n```\nSome(\n    Data {\n        name: \"John Doe\",\n        age: 45,\n    },\n)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantshandy%2Fdisk-persist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrantshandy%2Fdisk-persist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantshandy%2Fdisk-persist/lists"}