From 2beebf13d298f07cf6ad0aa1060ebd2c77be1d48 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Fri, 13 Mar 2026 10:38:01 +0100 Subject: [PATCH] style: apply rustfmt to all workspace crates --- crates/weft-app-shell/src/embedder.rs | 22 +++++++-------- crates/weft-app-shell/src/main.rs | 6 +---- crates/weft-appd/src/ipc.rs | 18 ++++++++++--- crates/weft-appd/src/main.rs | 10 ++++--- crates/weft-appd/src/runtime.rs | 5 +--- crates/weft-compositor/src/backend/winit.rs | 9 +++---- crates/weft-compositor/src/input.rs | 3 +-- crates/weft-compositor/src/state.rs | 4 ++- crates/weft-runtime/src/main.rs | 30 +++++++++++---------- crates/weft-servo-shell/src/embedder.rs | 20 +++----------- 10 files changed, 58 insertions(+), 69 deletions(-) diff --git a/crates/weft-app-shell/src/embedder.rs b/crates/weft-app-shell/src/embedder.rs index 193396e..0cff4d2 100644 --- a/crates/weft-app-shell/src/embedder.rs +++ b/crates/weft-app-shell/src/embedder.rs @@ -361,7 +361,9 @@ fn load_ui_kit_script() -> Option { #[allow(dead_code)] fn resolve_weft_system_url(url: &ServoUrl) -> Option { - if url.scheme() != "weft-system" { return None; } + if url.scheme() != "weft-system" { + return None; + } let host = url.host_str().unwrap_or(""); let path = url.path().trim_start_matches('/'); let system_root = std::env::var("WEFT_SYSTEM_RESOURCES") @@ -384,13 +386,11 @@ fn read_ui_entry(app_id: &str) -> Option { .join(app_id) .join("merged") .join("wapp.toml"); - let toml_text = std::fs::read_to_string(&erofs_manifest) - .ok() - .or_else(|| { - app_store_roots() - .into_iter() - .find_map(|r| std::fs::read_to_string(r.join(app_id).join("wapp.toml")).ok()) - })?; + let toml_text = std::fs::read_to_string(&erofs_manifest).ok().or_else(|| { + app_store_roots() + .into_iter() + .find_map(|r| std::fs::read_to_string(r.join(app_id).join("wapp.toml")).ok()) + })?; let m: Manifest = toml::from_str(&toml_text).ok()?; Some(m.ui.entry) } @@ -436,11 +436,7 @@ fn app_store_roots() -> Vec { roots } -pub fn run( - app_id: &str, - session_id: u64, - ws_port: u16, -) -> anyhow::Result<()> { +pub fn run(app_id: &str, session_id: u64, ws_port: u16) -> anyhow::Result<()> { let url = resolve_weft_app_url(app_id) .ok_or_else(|| anyhow::anyhow!("no ui/index.html found for app {app_id}"))?; diff --git a/crates/weft-app-shell/src/main.rs b/crates/weft-app-shell/src/main.rs index 849a065..0b80ff3 100644 --- a/crates/weft-app-shell/src/main.rs +++ b/crates/weft-app-shell/src/main.rs @@ -48,11 +48,7 @@ fn appd_ws_port() -> u16 { 7410 } -fn embed_app( - app_id: &str, - session_id: u64, - ws_port: u16, -) -> anyhow::Result<()> { +fn embed_app(app_id: &str, session_id: u64, ws_port: u16) -> anyhow::Result<()> { #[cfg(feature = "servo-embed")] return embedder::run(app_id, session_id, ws_port); diff --git a/crates/weft-appd/src/ipc.rs b/crates/weft-appd/src/ipc.rs index ad03580..84d7e4d 100644 --- a/crates/weft-appd/src/ipc.rs +++ b/crates/weft-appd/src/ipc.rs @@ -4,12 +4,22 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt}; #[derive(Debug, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "SCREAMING_SNAKE_CASE")] pub enum Request { - LaunchApp { app_id: String, surface_id: u64 }, - TerminateApp { session_id: u64 }, + LaunchApp { + app_id: String, + surface_id: u64, + }, + TerminateApp { + session_id: u64, + }, QueryRunning, - QueryAppState { session_id: u64 }, + QueryAppState { + session_id: u64, + }, QueryInstalledApps, - IpcForward { session_id: u64, payload: String }, + IpcForward { + session_id: u64, + payload: String, + }, PanelGesture { gesture_type: u32, fingers: u32, diff --git a/crates/weft-appd/src/main.rs b/crates/weft-appd/src/main.rs index 76b478d..4e96466 100644 --- a/crates/weft-appd/src/main.rs +++ b/crates/weft-appd/src/main.rs @@ -291,12 +291,14 @@ async fn handle_connection( ) -> anyhow::Result<()> { #[cfg(unix)] { - let cred = stream - .peer_cred() - .context("SO_PEERCRED")?; + let cred = stream.peer_cred().context("SO_PEERCRED")?; let our_uid = unsafe { libc::getuid() }; if cred.uid() != our_uid { - anyhow::bail!("peer UID {} != process UID {}; connection rejected", cred.uid(), our_uid); + anyhow::bail!( + "peer UID {} != process UID {}; connection rejected", + cred.uid(), + our_uid + ); } } diff --git a/crates/weft-appd/src/runtime.rs b/crates/weft-appd/src/runtime.rs index 0433fef..09008d0 100644 --- a/crates/weft-appd/src/runtime.rs +++ b/crates/weft-appd/src/runtime.rs @@ -145,10 +145,7 @@ async fn kill_portal(portal: Option<(PathBuf, tokio::process::Child)>) { } } -async fn spawn_app_shell( - session_id: u64, - app_id: &str, -) -> Option { +async fn spawn_app_shell(session_id: u64, app_id: &str) -> Option { let bin = std::env::var("WEFT_APP_SHELL_BIN").ok()?; let mut cmd = tokio::process::Command::new(&bin); cmd.arg(app_id) diff --git a/crates/weft-compositor/src/backend/winit.rs b/crates/weft-compositor/src/backend/winit.rs index ca26693..0f4a5ba 100644 --- a/crates/weft-compositor/src/backend/winit.rs +++ b/crates/weft-compositor/src/backend/winit.rs @@ -117,12 +117,9 @@ pub fn run() -> anyhow::Result<()> { output.set_preferred(new_mode); state.space.map_output(&output, (0, 0)); damage_tracker = OutputDamageTracker::from_output(&output); - state.weft_shell_state.reconfigure_panels( - 0, - 0, - size.w, - size.h, - ); + state + .weft_shell_state + .reconfigure_panels(0, 0, size.w, size.h); state.weft_shell_state.retain_alive_panels(); } WinitEvent::Input(input_event) => { diff --git a/crates/weft-compositor/src/input.rs b/crates/weft-compositor/src/input.rs index 1939cf8..7f2ac6e 100644 --- a/crates/weft-compositor/src/input.rs +++ b/crates/weft-compositor/src/input.rs @@ -338,8 +338,7 @@ fn handle_gesture_swipe_end( if !cancelled && gs.in_progress && gs.fingers >= NAVIGATION_SWIPE_FINGERS - && (gs.dx.abs() >= NAVIGATION_SWIPE_THRESHOLD - || gs.dy.abs() >= NAVIGATION_SWIPE_THRESHOLD) + && (gs.dx.abs() >= NAVIGATION_SWIPE_THRESHOLD || gs.dy.abs() >= NAVIGATION_SWIPE_THRESHOLD) { state .weft_shell_state diff --git a/crates/weft-compositor/src/state.rs b/crates/weft-compositor/src/state.rs index 577941d..bc06b14 100644 --- a/crates/weft-compositor/src/state.rs +++ b/crates/weft-compositor/src/state.rs @@ -500,7 +500,9 @@ impl Dispatch for WeftCompositorState { oy, ow, oh, - u32::from(crate::protocols::server::zweft_shell_window_v1::State::Maximized), + u32::from( + crate::protocols::server::zweft_shell_window_v1::State::Maximized, + ), ); state.weft_shell_state.add_panel(window); } else { diff --git a/crates/weft-runtime/src/main.rs b/crates/weft-runtime/src/main.rs index 01a8fff..3841805 100644 --- a/crates/weft-runtime/src/main.rs +++ b/crates/weft-runtime/src/main.rs @@ -246,9 +246,7 @@ fn run_module( Vec<(String, String)>, Option>, )| - -> wasmtime::Result<( - Result<(u16, String, Vec), String>, - )> { + -> wasmtime::Result<(Result<(u16, String, Vec), String>,)> { let result = host_fetch(&url, &method, &headers, body.as_deref()); Ok((result,)) }, @@ -395,7 +393,9 @@ fn host_clipboard_write(text: &str) -> Result<(), String> { .spawn() .map_err(|e| e.to_string())?; if let Some(stdin) = child.stdin.as_mut() { - stdin.write_all(text.as_bytes()).map_err(|e| e.to_string())?; + stdin + .write_all(text.as_bytes()) + .map_err(|e| e.to_string())?; } let status = child.wait().map_err(|e| e.to_string())?; if status.success() { @@ -412,15 +412,13 @@ fn host_notify(title: &str, body: &str, icon: Option<&str>) -> Result<(), String cmd.arg("--icon").arg(i); } cmd.arg("--").arg(title).arg(body); - cmd.status() - .map_err(|e| e.to_string()) - .and_then(|s| { - if s.success() { - Ok(()) - } else { - Err(format!("notify-send exited with {s}")) - } - }) + cmd.status().map_err(|e| e.to_string()).and_then(|s| { + if s.success() { + Ok(()) + } else { + Err(format!("notify-send exited with {s}")) + } + }) } #[cfg(feature = "seccomp")] @@ -473,7 +471,11 @@ fn apply_seccomp_filter() -> anyhow::Result<()> { )?; let bpf: BpfProgram = filter.try_into()?; let ret = unsafe { libc::prctl(libc::PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) }; - anyhow::ensure!(ret == 0, "prctl PR_SET_NO_NEW_PRIVS failed: {}", std::io::Error::last_os_error()); + anyhow::ensure!( + ret == 0, + "prctl PR_SET_NO_NEW_PRIVS failed: {}", + std::io::Error::last_os_error() + ); seccompiler::apply_filter(&bpf)?; Ok(()) } diff --git a/crates/weft-servo-shell/src/embedder.rs b/crates/weft-servo-shell/src/embedder.rs index a5b2bd0..f001817 100644 --- a/crates/weft-servo-shell/src/embedder.rs +++ b/crates/weft-servo-shell/src/embedder.rs @@ -99,11 +99,7 @@ struct App { } impl App { - fn new( - url: ServoUrl, - waker: WeftEventLoopWaker, - ws_port: u16, - ) -> Self { + fn new(url: ServoUrl, waker: WeftEventLoopWaker, ws_port: u16) -> Self { Self { url, ws_port, @@ -364,9 +360,7 @@ fn resolve_weft_app_url(url: &ServoUrl) -> Option { fn load_ui_kit_script() -> Option { let path = std::env::var("WEFT_UI_KIT_JS") .map(std::path::PathBuf::from) - .unwrap_or_else(|_| { - std::path::PathBuf::from("/usr/share/weft/system/weft-ui-kit.js") - }); + .unwrap_or_else(|_| std::path::PathBuf::from("/usr/share/weft/system/weft-ui-kit.js")); std::fs::read_to_string(path).ok() } @@ -388,10 +382,7 @@ fn app_store_roots() -> Vec { roots } -pub fn run( - html_path: &Path, - ws_port: u16, -) -> anyhow::Result<()> { +pub fn run(html_path: &Path, ws_port: u16) -> anyhow::Result<()> { let url_str = format!("file://{}", html_path.display()); let raw_url = ServoUrl::parse(&url_str).map_err(|e| anyhow::anyhow!("invalid URL {url_str}: {e}"))?; @@ -411,10 +402,7 @@ pub fn run( .map_err(|e| anyhow::anyhow!("event loop run: {e}")) } -fn forward_gestures_to_appd( - ws_port: u16, - gestures: &[crate::shell_client::PendingGesture], -) { +fn forward_gestures_to_appd(ws_port: u16, gestures: &[crate::shell_client::PendingGesture]) { use std::net::TcpStream; let addr = format!("127.0.0.1:{ws_port}"); let stream = match TcpStream::connect(&addr) {