Skip to content

Commit 170744f

Browse files
maxholmanclaude
andcommitted
fix(build): feature-gate serde_json out of slim build
serde_json was unconditionally included but only used for `wallhack peers --json`. Gate behind `json` feature (included in default, excluded from slim). Saves ~47KB in slim binary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 226eafb commit 170744f

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

crates/cli/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ name = "wallhackctl"
1212
path = "src/bin/wallhack.rs"
1313

1414
[features]
15-
default = ["quic", "websocket", "http-api", "repl"]
15+
default = ["quic", "websocket", "http-api", "repl", "json"]
16+
json = ["dep:serde_json"]
1617
slim = ["quic", "websocket"]
1718

1819
# Transport features (forwarded to wallhackd)
@@ -30,7 +31,7 @@ repl = ["dep:reedline", "dep:nu-ansi-term"]
3031
argh = "0.1"
3132
prost = "0.13"
3233
serde = { version = "1", features = ["derive"] }
33-
serde_json = "1"
34+
serde_json = { version = "1", optional = true }
3435
wallhack-ipc = { path = "../ipc" }
3536
rand = { version = "0.9", default-features = false, features = ["std", "std_rng"] }
3637
# Already a transitive dep via reedline — no additional binary cost.

crates/cli/src/bin/wallhack.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ async fn run_ctl_async(cli: wallhack_cli::cli::Cli) -> Result<(), output::CtlErr
309309
}),
310310
CtlCommand::Info(_) => management_request::Request::Status(StatusRequest {}),
311311
CtlCommand::Stats(_) => management_request::Request::Stats(StatsRequest {}),
312+
#[cfg(feature = "json")]
312313
CtlCommand::Peers(ref cmd) if cmd.json => {
313314
// JSON output: make the request and short-circuit the standard response path.
314315
let request = management_request::Request::Peers(PeersRequest {});

crates/cli/src/output.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
use std::io::Write;
44

55
use tabwriter::TabWriter;
6-
use wallhack_wire::management::{
7-
ManagementResponse, PeerInfo as WirePeerInfo, management_response,
8-
};
6+
use wallhack_wire::management::{ManagementResponse, management_response};
7+
8+
#[cfg(feature = "json")]
9+
use wallhack_wire::management::PeerInfo as WirePeerInfo;
910

1011
#[cfg(feature = "repl")]
1112
use {
@@ -15,6 +16,7 @@ use {
1516

1617
use crate::ipc::IpcError;
1718

19+
#[cfg(feature = "json")]
1820
#[derive(serde::Serialize)]
1921
struct PeerJson<'a> {
2022
name: &'a str,
@@ -50,6 +52,7 @@ fn format_uptime(ms: u64) -> String {
5052
/// Print the peers list as JSON to stdout.
5153
///
5254
/// Shape matches the REST API `/peers` response plus a `tun_name` field.
55+
#[cfg(feature = "json")]
5356
pub fn print_peers_json(peers: &[WirePeerInfo]) {
5457
let items: Vec<PeerJson<'_>> = peers
5558
.iter()

0 commit comments

Comments
 (0)