style: apply rustfmt to all workspace crates

This commit is contained in:
Marco Allegretti 2026-03-13 10:38:01 +01:00
parent 326d4d1452
commit 2beebf13d2
10 changed files with 58 additions and 69 deletions

View file

@ -361,7 +361,9 @@ fn load_ui_kit_script() -> Option<String> {
#[allow(dead_code)] #[allow(dead_code)]
fn resolve_weft_system_url(url: &ServoUrl) -> Option<ServoUrl> { fn resolve_weft_system_url(url: &ServoUrl) -> Option<ServoUrl> {
if url.scheme() != "weft-system" { return None; } if url.scheme() != "weft-system" {
return None;
}
let host = url.host_str().unwrap_or(""); let host = url.host_str().unwrap_or("");
let path = url.path().trim_start_matches('/'); let path = url.path().trim_start_matches('/');
let system_root = std::env::var("WEFT_SYSTEM_RESOURCES") let system_root = std::env::var("WEFT_SYSTEM_RESOURCES")
@ -384,9 +386,7 @@ fn read_ui_entry(app_id: &str) -> Option<String> {
.join(app_id) .join(app_id)
.join("merged") .join("merged")
.join("wapp.toml"); .join("wapp.toml");
let toml_text = std::fs::read_to_string(&erofs_manifest) let toml_text = std::fs::read_to_string(&erofs_manifest).ok().or_else(|| {
.ok()
.or_else(|| {
app_store_roots() app_store_roots()
.into_iter() .into_iter()
.find_map(|r| std::fs::read_to_string(r.join(app_id).join("wapp.toml")).ok()) .find_map(|r| std::fs::read_to_string(r.join(app_id).join("wapp.toml")).ok())
@ -436,11 +436,7 @@ fn app_store_roots() -> Vec<PathBuf> {
roots roots
} }
pub fn run( pub fn run(app_id: &str, session_id: u64, ws_port: u16) -> anyhow::Result<()> {
app_id: &str,
session_id: u64,
ws_port: u16,
) -> anyhow::Result<()> {
let url = resolve_weft_app_url(app_id) let url = resolve_weft_app_url(app_id)
.ok_or_else(|| anyhow::anyhow!("no ui/index.html found for app {app_id}"))?; .ok_or_else(|| anyhow::anyhow!("no ui/index.html found for app {app_id}"))?;

View file

@ -48,11 +48,7 @@ fn appd_ws_port() -> u16 {
7410 7410
} }
fn embed_app( fn embed_app(app_id: &str, session_id: u64, ws_port: u16) -> anyhow::Result<()> {
app_id: &str,
session_id: u64,
ws_port: u16,
) -> anyhow::Result<()> {
#[cfg(feature = "servo-embed")] #[cfg(feature = "servo-embed")]
return embedder::run(app_id, session_id, ws_port); return embedder::run(app_id, session_id, ws_port);

View file

@ -4,12 +4,22 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "SCREAMING_SNAKE_CASE")] #[serde(tag = "type", rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Request { pub enum Request {
LaunchApp { app_id: String, surface_id: u64 }, LaunchApp {
TerminateApp { session_id: u64 }, app_id: String,
surface_id: u64,
},
TerminateApp {
session_id: u64,
},
QueryRunning, QueryRunning,
QueryAppState { session_id: u64 }, QueryAppState {
session_id: u64,
},
QueryInstalledApps, QueryInstalledApps,
IpcForward { session_id: u64, payload: String }, IpcForward {
session_id: u64,
payload: String,
},
PanelGesture { PanelGesture {
gesture_type: u32, gesture_type: u32,
fingers: u32, fingers: u32,

View file

@ -291,12 +291,14 @@ async fn handle_connection(
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
#[cfg(unix)] #[cfg(unix)]
{ {
let cred = stream let cred = stream.peer_cred().context("SO_PEERCRED")?;
.peer_cred()
.context("SO_PEERCRED")?;
let our_uid = unsafe { libc::getuid() }; let our_uid = unsafe { libc::getuid() };
if cred.uid() != our_uid { 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
);
} }
} }

View file

@ -145,10 +145,7 @@ async fn kill_portal(portal: Option<(PathBuf, tokio::process::Child)>) {
} }
} }
async fn spawn_app_shell( async fn spawn_app_shell(session_id: u64, app_id: &str) -> Option<tokio::process::Child> {
session_id: u64,
app_id: &str,
) -> Option<tokio::process::Child> {
let bin = std::env::var("WEFT_APP_SHELL_BIN").ok()?; let bin = std::env::var("WEFT_APP_SHELL_BIN").ok()?;
let mut cmd = tokio::process::Command::new(&bin); let mut cmd = tokio::process::Command::new(&bin);
cmd.arg(app_id) cmd.arg(app_id)

View file

@ -117,12 +117,9 @@ pub fn run() -> anyhow::Result<()> {
output.set_preferred(new_mode); output.set_preferred(new_mode);
state.space.map_output(&output, (0, 0)); state.space.map_output(&output, (0, 0));
damage_tracker = OutputDamageTracker::from_output(&output); damage_tracker = OutputDamageTracker::from_output(&output);
state.weft_shell_state.reconfigure_panels( state
0, .weft_shell_state
0, .reconfigure_panels(0, 0, size.w, size.h);
size.w,
size.h,
);
state.weft_shell_state.retain_alive_panels(); state.weft_shell_state.retain_alive_panels();
} }
WinitEvent::Input(input_event) => { WinitEvent::Input(input_event) => {

View file

@ -338,8 +338,7 @@ fn handle_gesture_swipe_end<B: InputBackend>(
if !cancelled if !cancelled
&& gs.in_progress && gs.in_progress
&& gs.fingers >= NAVIGATION_SWIPE_FINGERS && gs.fingers >= NAVIGATION_SWIPE_FINGERS
&& (gs.dx.abs() >= NAVIGATION_SWIPE_THRESHOLD && (gs.dx.abs() >= NAVIGATION_SWIPE_THRESHOLD || gs.dy.abs() >= NAVIGATION_SWIPE_THRESHOLD)
|| gs.dy.abs() >= NAVIGATION_SWIPE_THRESHOLD)
{ {
state state
.weft_shell_state .weft_shell_state

View file

@ -500,7 +500,9 @@ impl Dispatch<ZweftShellManagerV1, ()> for WeftCompositorState {
oy, oy,
ow, ow,
oh, 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); state.weft_shell_state.add_panel(window);
} else { } else {

View file

@ -246,9 +246,7 @@ fn run_module(
Vec<(String, String)>, Vec<(String, String)>,
Option<Vec<u8>>, Option<Vec<u8>>,
)| )|
-> wasmtime::Result<( -> wasmtime::Result<(Result<(u16, String, Vec<u8>), String>,)> {
Result<(u16, String, Vec<u8>), String>,
)> {
let result = host_fetch(&url, &method, &headers, body.as_deref()); let result = host_fetch(&url, &method, &headers, body.as_deref());
Ok((result,)) Ok((result,))
}, },
@ -395,7 +393,9 @@ fn host_clipboard_write(text: &str) -> Result<(), String> {
.spawn() .spawn()
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
if let Some(stdin) = child.stdin.as_mut() { 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())?; let status = child.wait().map_err(|e| e.to_string())?;
if status.success() { if status.success() {
@ -412,9 +412,7 @@ fn host_notify(title: &str, body: &str, icon: Option<&str>) -> Result<(), String
cmd.arg("--icon").arg(i); cmd.arg("--icon").arg(i);
} }
cmd.arg("--").arg(title).arg(body); cmd.arg("--").arg(title).arg(body);
cmd.status() cmd.status().map_err(|e| e.to_string()).and_then(|s| {
.map_err(|e| e.to_string())
.and_then(|s| {
if s.success() { if s.success() {
Ok(()) Ok(())
} else { } else {
@ -473,7 +471,11 @@ fn apply_seccomp_filter() -> anyhow::Result<()> {
)?; )?;
let bpf: BpfProgram = filter.try_into()?; let bpf: BpfProgram = filter.try_into()?;
let ret = unsafe { libc::prctl(libc::PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) }; 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)?; seccompiler::apply_filter(&bpf)?;
Ok(()) Ok(())
} }

View file

@ -99,11 +99,7 @@ struct App {
} }
impl App { impl App {
fn new( fn new(url: ServoUrl, waker: WeftEventLoopWaker, ws_port: u16) -> Self {
url: ServoUrl,
waker: WeftEventLoopWaker,
ws_port: u16,
) -> Self {
Self { Self {
url, url,
ws_port, ws_port,
@ -364,9 +360,7 @@ fn resolve_weft_app_url(url: &ServoUrl) -> Option<ServoUrl> {
fn load_ui_kit_script() -> Option<String> { fn load_ui_kit_script() -> Option<String> {
let path = std::env::var("WEFT_UI_KIT_JS") let path = std::env::var("WEFT_UI_KIT_JS")
.map(std::path::PathBuf::from) .map(std::path::PathBuf::from)
.unwrap_or_else(|_| { .unwrap_or_else(|_| std::path::PathBuf::from("/usr/share/weft/system/weft-ui-kit.js"));
std::path::PathBuf::from("/usr/share/weft/system/weft-ui-kit.js")
});
std::fs::read_to_string(path).ok() std::fs::read_to_string(path).ok()
} }
@ -388,10 +382,7 @@ fn app_store_roots() -> Vec<PathBuf> {
roots roots
} }
pub fn run( pub fn run(html_path: &Path, ws_port: u16) -> anyhow::Result<()> {
html_path: &Path,
ws_port: u16,
) -> anyhow::Result<()> {
let url_str = format!("file://{}", html_path.display()); let url_str = format!("file://{}", html_path.display());
let raw_url = let raw_url =
ServoUrl::parse(&url_str).map_err(|e| anyhow::anyhow!("invalid URL {url_str}: {e}"))?; 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}")) .map_err(|e| anyhow::anyhow!("event loop run: {e}"))
} }
fn forward_gestures_to_appd( fn forward_gestures_to_appd(ws_port: u16, gestures: &[crate::shell_client::PendingGesture]) {
ws_port: u16,
gestures: &[crate::shell_client::PendingGesture],
) {
use std::net::TcpStream; use std::net::TcpStream;
let addr = format!("127.0.0.1:{ws_port}"); let addr = format!("127.0.0.1:{ws_port}");
let stream = match TcpStream::connect(&addr) { let stream = match TcpStream::connect(&addr) {