ServerBuilder

Struct ServerBuilder 

Source
pub struct ServerBuilder { /* private fields */ }
Expand description

Builder for configuring a Server.

use ghost_sync::Server;

let server = Server::builder()
    .bind("0.0.0.0:7777")
    .max_clients(128)
    .max_payload(128 * 1024)
    .build();

Implementations§

Source§

impl ServerBuilder

Source

pub fn new() -> Self

Source§

impl ServerBuilder

Source

pub fn bind(self, addr: impl Into<String>) -> Self

Set the bind address (e.g., "0.0.0.0:7777").

Source

pub fn max_clients(self, n: usize) -> Self

Set max concurrent clients. Connections beyond this are rejected.

Source

pub fn max_payload(self, n: usize) -> Self

Set max incoming payload size in bytes. Frames larger than this are rejected.

Source

pub fn idle_timeout(self, d: Duration) -> Self

Disconnect clients that send nothing for this duration. Any frame (including Pong) resets this timer. This is separate from ping-based liveness — see ping_interval.

Source

pub fn ping_interval(self, d: Duration) -> Self

How often the server pings clients. Pong deadline is one full ping_interval — if no Pong arrives before the next tick, the client is disconnected. This is separate from read inactivity — see idle_timeout.

Source

pub fn channel_capacity(self, n: usize) -> Self

Per-client write channel capacity. Frames are dropped when full (with on_backpressure hook). Higher values buffer more for bursty games, lower values keep latency tight. Default: 1024.

Source

pub fn handler(self, h: impl ServerHandler) -> Self

Set a custom event handler for lifecycle hooks.

Source

pub fn build(self) -> Server

Build the server. Call Server::run to start accepting connections.

Trait Implementations§

Source§

impl Default for ServerBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.