pub struct Server {
pub heartbeat_interval: Duration,
pub heartbeat_timeout: Duration,
pub port: u16,
pub ip: String,
pub static_path: Option<String>,
pub client_path: Option<String>,
}
Fields§
§heartbeat_interval: Duration
The duration of time between server-initiated WebSocket heartbeats.
Defaults to 30 seconds.
heartbeat_timeout: Duration
The minimum amount of time between client heartbeats before a connection is dropped.
Defaults to 5 minutes.
port: u16
The port to run the server on. Defaults to 8080.
ip: String
The IP to listen on. Defaults to 0.0.0.0.
static_path: Option<String>
A local filesystem path to serve static files from, or None (default).
client_path: Option<String>
A local filesystem path to serve from /client, or None (default).
Implementations§
Source§impl Server
impl Server
pub fn new() -> Self
pub fn with_static_path(self, static_path: Option<String>) -> Self
pub fn with_client_path(self, client_path: Option<String>) -> Self
pub fn with_heartbeat_interval(self, duration_seconds: u64) -> Self
pub fn with_heartbeat_timeout(self, duration_seconds: u64) -> Self
pub fn with_port(self, port: u16) -> Self
pub fn with_ip(self, ip: String) -> Self
Sourcepub async fn serve_async(
self,
factory: impl StateroomServiceFactory,
) -> Result<()>
pub async fn serve_async( self, factory: impl StateroomServiceFactory, ) -> Result<()>
Start a server given a [StateroomService].
This function blocks until the server is terminated. While it is running, the following endpoints are available:
/
(GET): return HTTP 200 if the server is running (useful as a baseline status check)/ws
(GET): initiate a WebSocket connection to the stateroom service.
Sourcepub fn serve(self, factory: impl StateroomServiceFactory) -> Result<()>
pub fn serve(self, factory: impl StateroomServiceFactory) -> Result<()>
Start a server given a [StateroomService].
This function blocks until the server is terminated. While it is running, the following endpoints are available:
/
(GET): return HTTP 200 if the server is running (useful as a baseline status check)/ws
(GET): initiate a WebSocket connection to the stateroom service.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Server
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnwindSafe for Server
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more