switch from rmp-serde to bincode

pull/9143/head
Ingrid 11 months ago
parent 25ef120da9
commit 2f13ad6360

61
Cargo.lock generated

@ -93,6 +93,25 @@ dependencies = [
"rustc-demangle", "rustc-demangle",
] ]
[[package]]
name = "bincode"
version = "2.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f11ea1a0346b94ef188834a65c068a03aec181c94896d481d7a0a40d85b0ce95"
dependencies = [
"bincode_derive",
"serde",
]
[[package]]
name = "bincode_derive"
version = "2.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e30759b3b99a1b802a7a3aa21c85c3ded5c28e1c83170d82d70f08bbf7f3e4c"
dependencies = [
"virtue",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.3.2"
@ -122,12 +141,6 @@ version = "3.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.4.0" version = "1.4.0"
@ -1426,6 +1439,7 @@ version = "24.7.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
"bincode",
"chrono", "chrono",
"content_inspector", "content_inspector",
"crossterm", "crossterm",
@ -1451,7 +1465,6 @@ dependencies = [
"open", "open",
"pulldown-cmark", "pulldown-cmark",
"same-file", "same-file",
"rmp-serde",
"serde", "serde",
"serde_json", "serde_json",
"signal-hook", "signal-hook",
@ -1883,12 +1896,6 @@ dependencies = [
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
[[package]]
name = "paste"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]] [[package]]
name = "pathdiff" name = "pathdiff"
version = "0.2.1" version = "0.2.1"
@ -2063,28 +2070,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rmp"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20"
dependencies = [
"byteorder",
"num-traits",
"paste",
]
[[package]]
name = "rmp-serde"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a"
dependencies = [
"byteorder",
"rmp",
"serde",
]
[[package]] [[package]]
name = "ropey" name = "ropey"
version = "1.6.1" version = "1.6.1"
@ -2586,6 +2571,12 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "virtue"
version = "0.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dcc60c0624df774c82a0ef104151231d37da4962957d691c011c852b2473314"
[[package]] [[package]]
name = "walkdir" name = "walkdir"
version = "2.4.0" version = "2.4.0"

@ -69,7 +69,7 @@ serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
# shada # shada
rmp-serde = "1.1.2" bincode = "2.0.0-rc.3"
# ripgrep for global search # ripgrep for global search
grep-regex = "0.1.12" grep-regex = "0.1.12"

@ -1,39 +1,36 @@
use bincode::{encode_into_std_write, Decode, Encode};
use helix_loader::{shada_file, VERSION_AND_GIT_HASH}; use helix_loader::{shada_file, VERSION_AND_GIT_HASH};
use helix_view::view::ViewPosition; // use helix_view::view::ViewPosition;
use rmp_serde::Serializer;
use serde::{Deserialize, Serialize};
use std::{ use std::{
fs::File, fs::File,
time::{SystemTime, UNIX_EPOCH}, time::{SystemTime, UNIX_EPOCH},
}; };
// TODO: should this be non-exhaustive? // TODO: should this be non-exhaustive?
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Encode, Decode)]
#[serde(rename = "H")]
struct Header { struct Header {
generator: String, generator: String,
version: String, version: String,
encoding: String,
max_kbyte: u32, max_kbyte: u32,
pid: u32, pid: u32,
} }
// TODO: should this be non-exhaustive? // TODO: should this be non-exhaustive?
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Encode, Decode)]
struct FilePosition { struct FilePosition {
path: String, path: String,
position: ViewPosition, // position: ViewPosition,
} }
// TODO: should this be non-exhaustive? // TODO: should this be non-exhaustive?
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Encode, Decode)]
enum EntryData { enum EntryData {
Header(Header), Header(Header),
FilePosition(FilePosition), FilePosition(FilePosition),
} }
// TODO: should this be non-exhaustive? // TODO: should this be non-exhaustive?
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Encode, Decode)]
struct Entry { struct Entry {
timestamp: u64, timestamp: u64,
data: EntryData, data: EntryData,
@ -52,9 +49,6 @@ fn generate_header() -> Entry {
data: EntryData::Header(Header { data: EntryData::Header(Header {
generator: "helix".to_string(), generator: "helix".to_string(),
version: VERSION_AND_GIT_HASH.to_string(), version: VERSION_AND_GIT_HASH.to_string(),
// TODO: is this necessary? helix doesn't seem to expose an option
// for internal encoding like nvim does
encoding: "utf-8".to_string(),
max_kbyte: 100, max_kbyte: 100,
pid: std::process::id(), pid: std::process::id(),
}), }),
@ -65,11 +59,10 @@ pub fn write_shada_file() {
// TODO: merge existing file if exists // TODO: merge existing file if exists
// TODO: do something about this unwrap // TODO: do something about this unwrap
let shada_file = File::create(shada_file()).unwrap(); let mut shada_file = File::create(shada_file()).unwrap();
let mut serializer = Serializer::new(shada_file);
let header = generate_header(); let header = generate_header();
// TODO: do something about this unwrap // TODO: do something about this unwrap
header.serialize(&mut serializer).unwrap(); encode_into_std_write(&header, &mut shada_file, bincode::config::standard()).unwrap();
} }

@ -18,8 +18,6 @@ use helix_core::{
VisualOffsetError::{PosAfterMaxRow, PosBeforeAnchorRow}, VisualOffsetError::{PosAfterMaxRow, PosBeforeAnchorRow},
}; };
use serde::{Deserialize, Serialize};
use std::{ use std::{
collections::{HashMap, VecDeque}, collections::{HashMap, VecDeque},
fmt, fmt,
@ -120,7 +118,7 @@ impl JumpList {
} }
} }
#[derive(Clone, Debug, PartialEq, Eq, Copy, Default, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Copy, Default)]
pub struct ViewPosition { pub struct ViewPosition {
pub anchor: usize, pub anchor: usize,
pub horizontal_offset: usize, pub horizontal_offset: usize,

Loading…
Cancel
Save