Expand description
Cross-platform local socket seam, the owner-tree endpoint over it, and the per-user runtime directory that names both.
v2 keeps every local socket in one machine-level runtime directory:
$ONLYNE_RUNTIME_DIR when the operator sets it, /tmp/onlyne-<uid>/
otherwise, created 0700 and adopted only when this process owns it alone.
One workspace owns two files there, both named by workspace_digest — the
first 16 hex characters of sha256 over the canonical workspace root:
<digest>.sock: the socketbind_socket_v2binds andconnect_localreaches,0600.<digest>.json: theRegistrationFilenaming who serves it — kind, role, root, pid, version, runtime.read_registration,registration_path, andlist_registrationsare the discovery seam the CLI, the test harness, and external-runtime plugins read instead of walking workspace trees.
v1 kept the socket at <run_dir>/s while that spelling fit sun_path, moved
it to a short derived path when it did not, and published the choice in
run/socket. A generated role nests deep enough
(<root>/.onlyne/ws/<topology>/<role>/.onlyne/run/s) that the canonical
spelling passes UNIX_SOCKET_PATH_MAX, so the two-rule answer split one
tree across two directories depending on who resolved when. The runtime path
is about 40 bytes for any root, so one tree owns one spelling, and
<run_dir>/s survives only as SocketEndpoint::natural, the spelling
operators and older tooling print.
The unix base is /tmp rather than std::env::temp_dir because a
launchd-started daemon and an interactive shell see different TMPDIR and
XDG_RUNTIME_DIR values; one fixed base makes every context compute the same
path for the same root.
Windows cannot bind a UDS on stable 1.85, so <digest>.sock there is a
regular marker file whose contents name an NPFS pipe (v1:onlyne-<32hex>)
and the pipe carries the traffic. --socket values that already start with a
verbatim pipe path skip derivation and travel as GenericFilePath. Frame I/O
stays generic AsyncRead/AsyncWrite.
create_dir, set_dir_mode, and apply_private_mode are the mode half
of the same seam: one spelling of “owner-only run/, keys/, and runtime
directory” for the daemon that binds and the layout that bootstraps.
Modules§
- prelude
- Traits needed to
.accept()/.connect()the interprocess types.
Structs§
- Registration
File - The one file that names a workspace’s endpoint:
<runtime>/<digest>.json. - Socket
Endpoint - The owner tree’s local socket: the path v2 binds, the canonical spelling v1 bound, the registration that names it, and the root all three derive from.
Enums§
- Layout
Error - Errors produced by the owner-only mode helpers below.
- Registration
Kind - Which side of a socket one
RegistrationFiledescribes.
Constants§
- REGISTRATION_
SUFFIX - Registration leaf inside a runtime directory:
<digest>.json. - RUNTIME_
DIR_ ENV - Environment variable that replaces the default runtime directory, used verbatim when set and non-empty.
- SOCKET_
FILE_ NAME - Socket file name inside
run/, the canonical spelling every v1 layout path used. v2 binds elsewhere and keeps this only asSocketEndpoint::natural. - SOCKET_
SUFFIX - Socket leaf inside a runtime directory:
<digest>.sock. - UNIX_
SOCKET_ PATH_ MAX - Bytes available in
sun_pathon unix, including the trailing NUL. macOS allows 104. - WIRE_
VERSION - The version of the wire protocol this crate speaks, the
versioneveryRegistrationFilewritten here carries, so a reader can tell which protocol a live endpoint expects.
Functions§
- absolute_
path - Absolute, symlink-free spelling of a path when it exists, its lexical absolute otherwise.
- apply_
private_ mode - Apply
0600to an existing private file. - bind_
local - Bind a tokio listener at
path. - bind_
local_ sync - Blocking bind, used by CLI tests that serve one frame on a helper thread.
- bind_
local_ sync_ poll - Blocking bind whose
acceptreturnsWouldBlockwhen no client is waiting. - bind_
socket - Bind the owner tree’s local socket at
socket_pathin the runtime directory and return it with the endpoint that names it. - bind_
socket_ registered - Bind the owner tree’s socket and publish
regfor it in one call, for a daemon that knows its surface at start. - bind_
socket_ v2 - Bind the owner tree’s socket in the runtime directory.
- bind_
tokio - Synchronous counterpart of
bind_localfor the tokio listener type. - connect_
local - Connect to the listener that
bind_localcreated forpath. - connect_
local_ sync - Blocking connect matching
bind_local_sync. - create_
dir - Create a directory, optionally setting its mode.
- is_
verbatim_ pipe_ path truewhen--socketis already an NPFS path and must not be hashed.- list_
registrations - Every registration this machine’s runtime directory holds, sorted by file path.
- pipe_
name_ for - NPFS leaf
onlyne-<32hex>derived frompathwithout touching the filesystem. - read_
registration - The registration for
root, orNonewhen nothing published one. - registration_
path - The registration belonging to
socket_path’s socket,<runtime_dir>/<workspace_digest>.json. - remove_
registration - Remove the registration for
root. Removing nothing is not an error. - runtime_
dir - The runtime directory, created and owner-verified.
- runtime_
dir_ path - The runtime directory’s spelling without creating or checking anything, so a
caller can name a path before any daemon exists (
/tmpis one component). - set_
dir_ mode - socket_
path - The socket one workspace owns:
<runtime_dir>/<workspace_digest>.sock. - workspace_
digest - Identity of one owner tree:
sha256of its canonical spelling, the first 16 lowercase hex characters. - write_
registration - Publish
regas the registration forroot, creating the runtime directory.
Type Aliases§
- Local
Listener - Tokio listener produced by
bind_local. - Local
Listener Sync - Blocking listener for tests that cannot run inside a tokio runtime.
- Local
Stream - Tokio stream produced by
connect_localorLocalListener::accept. - Local
Stream Sync - Blocking stream matching
LocalListenerSync.