From eb2c76400ad85f9a2231f08fcb89790dd6becd2a Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Tue, 23 Jun 2026 09:19:30 +0200 Subject: [PATCH] Rust fmt --- bin/silverbullet/src/config.rs | 3 +-- bin/silverbullet/src/server.rs | 4 +++- server-common/src/upgrade.rs | 6 +++++- server-runtime-chrome/src/config.rs | 5 ++++- server/src/handlers/runtime.rs | 9 +++++---- server/src/runtime/client.rs | 8 ++++---- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/bin/silverbullet/src/config.rs b/bin/silverbullet/src/config.rs index 01640f52..d589a39b 100644 --- a/bin/silverbullet/src/config.rs +++ b/bin/silverbullet/src/config.rs @@ -90,8 +90,7 @@ impl Config { disable_service_worker: env_nonempty("SB_DISABLE_SERVICE_WORKER").is_some(), log_push: env_nonempty("SB_LOG_PUSH").is_some(), additional_head_html: env::var("SB_HEAD_HTML").unwrap_or_default(), - theme_color: env_nonempty("SB_THEME_COLOR") - .unwrap_or_else(|| "#e1e1e1".to_string()), + theme_color: env_nonempty("SB_THEME_COLOR").unwrap_or_else(|| "#e1e1e1".to_string()), space_description: env_nonempty("SB_DESCRIPTION") .unwrap_or_else(|| "Powerful and programmable note taking app".to_string()), host_url_prefix: normalize_prefix(&env::var("SB_URL_PREFIX").unwrap_or_default()), diff --git a/bin/silverbullet/src/server.rs b/bin/silverbullet/src/server.rs index ebf364ff..fcccfec2 100644 --- a/bin/silverbullet/src/server.rs +++ b/bin/silverbullet/src/server.rs @@ -123,7 +123,9 @@ fn build_runtime( let logs = silverbullet_server::runtime::LogBuffer::new(); match silverbullet_server_runtime_chrome::ChromeTransport::launch(chrome_cfg, logs.clone()) { Ok(transport) => { - tracing::info!("headless Chrome runtime configured (launches on first runtime request)"); + tracing::info!( + "headless Chrome runtime configured (launches on first runtime request)" + ); Some(Box::new(silverbullet_server::runtime::ClientRuntime::new( transport, logs, ))) diff --git a/server-common/src/upgrade.rs b/server-common/src/upgrade.rs index fef90c9f..f523d444 100644 --- a/server-common/src/upgrade.rs +++ b/server-common/src/upgrade.rs @@ -88,7 +88,11 @@ fn do_upgrade( .map_err(|e| format!("failed to read response: {e}"))?; std::fs::write(&zip_path, &bytes).map_err(|e| format!("failed to save zip file: {e}"))?; - println!("Replacing {} binary in {}", spec.binary, install_dir.display()); + println!( + "Replacing {} binary in {}", + spec.binary, + install_dir.display() + ); extract_zip(&zip_path, install_dir)?; diff --git a/server-runtime-chrome/src/config.rs b/server-runtime-chrome/src/config.rs index ee3a838b..b27e25c0 100644 --- a/server-runtime-chrome/src/config.rs +++ b/server-runtime-chrome/src/config.rs @@ -41,7 +41,10 @@ impl ChromeConfig { env("SB_CHROME_SHOW").is_some(), // On by default; disabled only with SB_CHROME_LOG_CONSOLE=0/false // (matches the SB_RUNTIME_API opt-out convention). - !matches!(env("SB_CHROME_LOG_CONSOLE").as_deref(), Some("0") | Some("false")), + !matches!( + env("SB_CHROME_LOG_CONSOLE").as_deref(), + Some("0") | Some("false") + ), read_only, runtime_api_enabled, ) diff --git a/server/src/handlers/runtime.rs b/server/src/handlers/runtime.rs index 2e5fea62..137dc54e 100644 --- a/server/src/handlers/runtime.rs +++ b/server/src/handlers/runtime.rs @@ -183,9 +183,7 @@ mod tests { match self.eval.as_ref().err().unwrap() { RuntimeErrorKind::NotReady => RuntimeError::NotReady, RuntimeErrorKind::Timeout => RuntimeError::Timeout, - RuntimeErrorKind::Eval => { - RuntimeError::Eval("attempt to call a nil value".into()) - } + RuntimeErrorKind::Eval => RuntimeError::Eval("attempt to call a nil value".into()), } } } @@ -267,7 +265,10 @@ mod tests { assert_eq!(status, StatusCode::INTERNAL_SERVER_ERROR); assert!(body.contains("script_error"), "{body}"); // The clean message flows verbatim into the `error` field (no Debug dump). - assert!(body.contains(r#""error":"attempt to call a nil value""#), "{body}"); + assert!( + body.contains(r#""error":"attempt to call a nil value""#), + "{body}" + ); } #[tokio::test] diff --git a/server/src/runtime/client.rs b/server/src/runtime/client.rs index bb4c0b13..75f85acf 100644 --- a/server/src/runtime/client.rs +++ b/server/src/runtime/client.rs @@ -46,10 +46,10 @@ impl RuntimeBackend for ClientRuntime { // evalLuaScript, objectsAPI), so a failure here — the runtime not // coming up, a timeout, or a thrown error in the client (e.g. a Lua // error) — always leaves a trace in the server log. - let result = self - .transport - .wait_ready(timeout) - .and_then(|()| self.transport.eval_js(&build_global_call_js(fn_name, arg), timeout)); + let result = self.transport.wait_ready(timeout).and_then(|()| { + self.transport + .eval_js(&build_global_call_js(fn_name, arg), timeout) + }); if let Err(e) = &result { tracing::warn!("runtime call {fn_name} failed: {e}"); }