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)]
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 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<String> {
.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<PathBuf> {
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}"))?;

View file

@ -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);

View file

@ -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,

View file

@ -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
);
}
}

View file

@ -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<tokio::process::Child> {
async fn spawn_app_shell(session_id: u64, app_id: &str) -> Option<tokio::process::Child> {
let bin = std::env::var("WEFT_APP_SHELL_BIN").ok()?;
let mut cmd = tokio::process::Command::new(&bin);
cmd.arg(app_id)

View file

@ -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) => {

View file

@ -338,8 +338,7 @@ fn handle_gesture_swipe_end<B: InputBackend>(
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

View file

@ -500,7 +500,9 @@ impl Dispatch<ZweftShellManagerV1, ()> 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 {

View file

@ -246,9 +246,7 @@ fn run_module(
Vec<(String, String)>,
Option<Vec<u8>>,
)|
-> wasmtime::Result<(
Result<(u16, String, Vec<u8>), String>,
)> {
-> wasmtime::Result<(Result<(u16, String, Vec<u8>), 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(())
}

View file

@ -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<ServoUrl> {
fn load_ui_kit_script() -> Option<String> {
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<PathBuf> {
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) {