dioxus_storage/
lib.rs

1//! <div align="center">
2//!   <h1>dioxus_storage</h1>
3//! </div>
4//! <div align="center">
5//!   <!-- Crates version -->
6//!   <a href="https://crates.io/crates/dioxus_storage">
7//!     <img src="https://img.shields.io/crates/v/dioxus_storage.svg?style=flat-square"
8//!     alt="Crates.io version" />
9//!   </a>
10//!   <!-- Downloads -->
11//!   <a href="https://crates.io/crates/dioxus_storage">
12//!     <img src="https://img.shields.io/crates/d/dioxus_storage.svg?style=flat-square"
13//!       alt="Download" />
14//!   </a>
15//!   <!-- docs -->
16//!   <a href="https://docs.rs/dioxus_storage">
17//!     <img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square"
18//!       alt="docs.rs docs" />
19//!   </a>
20//! </div>
21
22//! # dioxus-storage
23
24//! A library for handling local storage ergonomically in Dioxus
25
26//! ## Usage
27
28//! ```rust
29//! use dioxus_storage::use_storage;
30//! use dioxus::prelude::*;
31
32//! fn main() {
33//!     dioxus_web::launch(app)
34//! }
35
36//! fn app(cx: Scope) -> Element {
37//!     let num = use_persistent(cx, "count", || 0);
38
39//!     cx.render(rsx! {
40//!         div {
41//!             button {
42//!                 onclick: move |_| {
43//!                     num.modify(|num| *num += 1);
44//!                 },
45//!                 "Increment"
46//!             }
47//!             div {
48//!                 "{*num.read()}"
49//!             }
50//!         }
51//!     })
52//! }
53//! ```
54
55mod client_storage;
56mod storage;
57
58#[cfg(not(target_arch = "wasm32"))]
59pub use client_storage::{set_dir_name, set_directory};
60
61pub use client_storage::{use_persistent, UsePersistent, StorageRef, StorageRefMut, ClientStorage};
62pub use storage::{StorageBacking, StorageEntry};
63
64pub use once_cell;
65pub use postcard;