1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 23:00:04 -04:00

egui_inspection: cross-platform local socket via interprocess

Replace std::os::unix::net::UnixStream in the InspectionPlugin with the
interprocess crate's local_socket::Stream, so the transport works on Windows
(named pipe) as well as unix/macOS (unix domain socket).

- New transport module (transport feature) with socket_name() and
  generate_socket_target() — one shared, platform-split place to build/allocate
  local-socket names, used by both ends of the connection.
- Drop the cfg(unix) gates on the plugin module; gate on the plugin feature only.
- attach() now takes a socket name string and connects via interprocess; the
  stream is split with Stream::split() instead of UnixStream::try_clone().
This commit is contained in:
lucasmerlin
2026-05-26 14:15:47 +02:00
parent 622218e94f
commit d67862ace6
5 changed files with 136 additions and 26 deletions

View File

@@ -27,10 +27,15 @@ default = ["protocol"]
## MessagePack framing helpers. No `egui` dependency beyond `egui::accesskit`.
protocol = ["dep:rmp-serde", "dep:serde", "dep:serde_bytes", "egui/serde"]
## Cross-platform local-socket name helpers ([`transport::socket_name`],
## [`transport::generate_socket_target`]) built on `interprocess`: unix domain sockets on
## unix, named pipes on Windows. Shared by both ends of the connection.
transport = ["dep:interprocess", "dep:tempfile"]
## `InspectionPlugin` — an `egui::Plugin` impl that streams frames + accesskit tree to
## an inspector over a unix socket and applies received commands. Auto-attaches when
## an inspector over a local socket and applies received commands. Auto-attaches when
## the [`INSPECTION_SOCKET_ENV_VAR`] env var is set.
plugin = ["protocol", "dep:image"]
plugin = ["protocol", "transport", "dep:image"]
[dependencies]
egui.workspace = true
@@ -38,6 +43,8 @@ serde = { workspace = true, optional = true }
serde_bytes = { version = "0.11.17", optional = true }
rmp-serde = { workspace = true, optional = true }
image = { workspace = true, optional = true }
interprocess = { version = "2.4", optional = true }
tempfile = { workspace = true, optional = true }
document-features = { workspace = true, optional = true }