Expand description
Shared sync→async bridge for 9P-style Mount implementations that proxy
to a Cap’n Proto RPC service (nine.capnp envelope).
Both RemoteModelMount (1-level scope: first path component = model ref)
and RemoteRegistryMount (2-level scope: repo → worktree, with async UUID
resolution) translate synchronous VFS Mount trait calls into async RPC
requests by embedding a dedicated single-threaded tokio runtime and
block_on-ing each op. The runtime, the local-fid allocator, the
DashMap<u32, S> that tracks remote fid state, the anyhow → MountError
mapping, the opaque RemoteFidKey newtype stored in Fid, and the packed
9P stat parser used for directory reads are identical across the two
mounts — only the RPC client type, the scope extraction, and which RPC
method names / directory byte format differ.
This module factors out the shared pieces:
NinePBridge<S>— owns the runtime + fid map + fid allocator. Each mount holds one of these and supplies its own fid-state typeS.map_err—anyhow::Error → MountErrorclassification.RemoteFidKey— the opaque newtype stored insidehyprstream_vfs::Fid.parse_dir_stats— decode packed 9P stat entries from a directoryread()response (the format the model service’sSyntheticTreeemits).
What stays mount-specific:
- the top-level
Mountimpl (walk’s scope extraction differs: 1-level vs 2-level with asyncget_by_nameresolution), - the request-struct construction (each generated client module has its
own
NpWalk/NpOpen/… types), - the stat RPC method name (
statonModelFsClient,np_statonWorktreeClient), - the directory-entry byte format (packed 9P stats for the model service
vs
name_len+name+is_dir+sizefor the registry worktree service).
Structs§
- NineP
Bridge - Shared sync→async bridge plumbing for a 9P
Mountproxying to a Cap’n Proto RPC service. - Remote
FidKey - Newtype stored inside the opaque
hyprstream_vfs::Fid.
Functions§
- fid_key
- Downcast the opaque
Fidto itsRemoteFidKey, returningMountError::InvalidArgumenton a type mismatch. AllMountops start with this. Free-standing so callers don’t need to name the bridge’s fid-state type parameter. - map_err
- Classify an
anyhow::Error(as surfaced by the generated RPC clients) into aMountErrorby string-matching the common 9P / filesystem error phrases. Identical for every backing service. Free-standing so callers don’t need to name the bridge’s fid-state type parameter. - parse_
dir_ stats - Parse packed 9P stat entries from a directory
read()response.