pub struct ShellServer { /* private fields */ }Expand description
A bound-but-not-yet-serving shell server.
Implementations§
Source§impl ShellServer
impl ShellServer
Sourcepub async fn bind(config: ShellConfig) -> Result<Self, HostError>
pub async fn bind(config: ShellConfig) -> Result<Self, HostError>
Validates the asset root and the served config contract, then binds the listener.
§Errors
Refuses an unreadable or non-directory asset root, a root without
index.html, a config the shell’s contract would refuse (empty
busEndpoint, empty provided channel), and any bind failure —
all typed. Serving a config the shell will refuse at parse time is a
composition error the host catches here, not in the browser.
Sourcepub fn adopt(
listener: TcpListener,
config: ShellConfig,
) -> Result<Self, HostError>
pub fn adopt( listener: TcpListener, config: ShellConfig, ) -> Result<Self, HostError>
Adopts an ALREADY-BOUND listener (from crate::page::PageServer)
instead of binding its own, then validates the served config contract
exactly as Self::bind does.
The page-server port is resolved and BOUND up front (prefer-and-walk, or
stated-and-exact) before the embedded bus boots, so its real address can
seed the bus’s derived origin allow-list. Handing the held listener
straight here — rather than probing a port, dropping it, and re-binding
— is what makes that resolution race-free: no other process can claim
the port in between. config.bind is ignored (the listener is already
bound); the real bound address is read from the listener itself.
§Errors
Refuses the same config-contract and asset-root violations as
Self::bind, and any failure converting the adopted std listener to a
non-blocking async listener.
Sourcepub const fn local_addr(&self) -> SocketAddr
pub const fn local_addr(&self) -> SocketAddr
The address actually bound (resolves an ephemeral port request).