Skip to content

Commit

Permalink
migrate to bincode
Browse files Browse the repository at this point in the history
  • Loading branch information
bluskript committed Jul 28, 2023
1 parent 38c95d8 commit 8155fd7
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 175 deletions.
126 changes: 27 additions & 99 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions lsp-positions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ test = false

[features]
default = ["tree-sitter"]
rkyv = ["dep:rkyv"]
bincode = ["dep:bincode"]

[dependencies]
memchr = "2.4"
tree-sitter = { version=">= 0.19", optional=true }
unicode-segmentation = { version="1.8" }
serde = { version="1", optional=true, features=["derive"] }
rkyv = { version="0.7.42", optional=true }
bincode = { version="2.0.0-rc.3", optional=true }
12 changes: 6 additions & 6 deletions lsp-positions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ fn utf16_len(string: &str) -> usize {
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct Position {
/// The 0-indexed line number containing the character
Expand Down Expand Up @@ -113,8 +113,8 @@ impl PartialOrd<tree_sitter::Point> for Position {
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct Span {
pub start: Position,
Expand Down Expand Up @@ -153,8 +153,8 @@ impl PartialOrd for Span {
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct Offset {
/// The number of UTF-8-encoded bytes appearing before this character in the string
Expand Down
6 changes: 3 additions & 3 deletions stack-graphs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ edition = "2018"
[features]
copious-debugging = []
serde = ["dep:serde", "lsp-positions/serde"]
rkyv = ["dep:rkyv", "lsp-positions/rkyv"]
storage = ["rkyv", "rusqlite", "serde"]
bincode = ["dep:bincode", "lsp-positions/bincode"]
storage = ["bincode", "rusqlite", "serde"]
visualization = ["serde", "serde_json"]

[lib]
Expand All @@ -32,7 +32,7 @@ fxhash = "0.2"
itertools = "0.10"
libc = "0.2"
lsp-positions = { version = "0.3", path = "../lsp-positions" }
rkyv = { version = "0.7.42", optional = true }
bincode = { version = "2.0.0-rc.3", optional = true }
rusqlite = { version = "0.28", optional = true, features = ["bundled", "functions"] }
serde = { version = "1.0", optional = true, features = ["derive"] }
serde_json = { version = "1.0", optional = true }
Expand Down
40 changes: 20 additions & 20 deletions stack-graphs/src/serde/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use super::NoFilter;

#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct StackGraph {
pub files: Files,
Expand Down Expand Up @@ -208,8 +208,8 @@ impl StackGraph {

#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
#[serde(transparent)]
pub struct Files {
Expand All @@ -218,8 +218,8 @@ pub struct Files {

#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
#[serde(transparent)]
pub struct Nodes {
Expand All @@ -229,8 +229,8 @@ pub struct Nodes {
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "type", rename_all = "snake_case")]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub enum Node {
DropScopes {
Expand Down Expand Up @@ -340,8 +340,8 @@ impl Node {

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct SourceInfo {
pub span: lsp_positions::Span,
Expand All @@ -352,17 +352,17 @@ pub struct SourceInfo {
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(transparent)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct DebugInfo {
pub data: Vec<DebugEntry>,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct DebugEntry {
pub key: String,
Expand All @@ -371,8 +371,8 @@ pub struct DebugEntry {

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct NodeID {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -433,17 +433,17 @@ impl std::fmt::Display for NodeID {
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(transparent)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct Edges {
pub data: Vec<Edge>,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
feature = "bincode",
derive(bincode::Encode, bincode::Decode)
)]
pub struct Edge {
pub source: NodeID,
Expand Down
Loading

0 comments on commit 8155fd7

Please sign in to comment.