pub struct PreviewServer {
pub port: u16,
/* private fields */
}Expand description
A running preview server.
Obtained from start_preview_server. Serves frames from the embedded
Registry over HTTP on a loopback port at /preview/{id}.bin. Each
response is a 24-byte binary header followed by raw pixel data, see
PREVIEW_JS for the client-side decoder.
Clone freely, all state is shared behind Arcs. The listener thread lives
exactly as long as the last clone; dropping every PreviewServer shuts
the server down cleanly.
The port field is public so callers can read it directly. The embedded
Registry is crate-private because the canonical way to access it is
use_context::<Registry>() after calling
register_with at launch time.
§Coupling to Registry
The server is deliberately hard-coded to read from Registry rather
than being generic over a custom frame-source trait. Internally the
listener does use a pub(crate) FrameSource abstraction so swapping is
a small change if it ever becomes necessary, but exposing that surface
publicly would let users plug in a custom source that the bundled hooks
(use_camera_stream) silently do not write
to, which is a worse footgun than the coupling. If your app needs a
non-Registry frame source, open a PR and we’ll cut a typed entry
point.
Fields§
§port: u16The TCP port the server is listening on.
Trait Implementations§
Source§impl Clone for PreviewServer
impl Clone for PreviewServer
Source§fn clone(&self) -> PreviewServer
fn clone(&self) -> PreviewServer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more