Skip to content

Commit

Permalink
replace rmp_serde with cbor
Browse files Browse the repository at this point in the history
it is more standard
  • Loading branch information
SeaDve committed Jan 8, 2024
1 parent 99d31ee commit 0317119
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 51 deletions.
61 changes: 17 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ gtk = { version = "0.7", package = "gtk4", features = ["gnome_45"] }
gtk_source = { package = "sourceview5", version = "0.7", features = ["v5_10"] }
indexmap = "2.1"
regex = "1.10.2"
rmp-serde = "1.1.2"
serde = { version = "1", features = ["derive"] }
serde_cbor = "0.11.2"
tracing = "0.1.37"
tracing-subscriber = "0.3"
webkit = { package = "webkit6", version = "0.2.0", features = ["v2_42"] }
6 changes: 3 additions & 3 deletions src/recent_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod imp {

fn new() -> Self {
Self {
state_file: gio::File::for_path(APP_DATA_DIR.join("recents.msgpack")),
state_file: gio::File::for_path(APP_DATA_DIR.join("recents.cbor")),
list: RefCell::new(IndexMap::new()),
}
}
Expand Down Expand Up @@ -80,7 +80,7 @@ impl RecentList {
let now = Instant::now();

let state = match imp.state_file.load_bytes_future().await {
Ok((bytes, _)) => rmp_serde::from_slice::<State>(&bytes)?,
Ok((bytes, _)) => serde_cbor::from_slice::<State>(&bytes)?,
Err(err) => {
if !err.matches(gio::IOErrorEnum::NotFound) {
return Err(err.into());
Expand Down Expand Up @@ -136,7 +136,7 @@ impl RecentList {
};
tracing::trace!(?state, "State stored");

let bytes = rmp_serde::to_vec_named(&state)?;
let bytes = serde_cbor::to_vec(&state)?;
imp.state_file
.replace_contents_future(
bytes,
Expand Down
6 changes: 3 additions & 3 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ mod imp {

fn new() -> Self {
Self {
state_file: gio::File::for_path(APP_DATA_DIR.join("state.msgpack")),
state_file: gio::File::for_path(APP_DATA_DIR.join("state.cbor")),
default_window_width: Cell::new(DEFAULT_WINDOW_WIDTH),
default_window_height: Cell::new(DEFAULT_WINDOW_HEIGHT),
windows: RefCell::default(),
Expand Down Expand Up @@ -358,7 +358,7 @@ impl Session {
let now = Instant::now();

let state = match imp.state_file.load_bytes_future().await {
Ok((bytes, _)) => rmp_serde::from_slice::<State>(&bytes)?,
Ok((bytes, _)) => serde_cbor::from_slice::<State>(&bytes)?,
Err(err) => {
if !err.matches(gio::IOErrorEnum::NotFound) {
return Err(err.into());
Expand Down Expand Up @@ -417,7 +417,7 @@ impl Session {
};
tracing::trace!(?state, "State stored");

let bytes = rmp_serde::to_vec_named(&state)?;
let bytes = serde_cbor::to_vec(&state)?;
imp.state_file
.replace_contents_future(
bytes,
Expand Down

0 comments on commit 0317119

Please sign in to comment.