pub struct Server { /* private fields */ }Expand description
Owner of a persistent server stream, accepting successive sessions.
Closing or dropping the server ends its active session and shuts down the
physical stream. Closing an individual Session keeps this owner and
its stream available for another handshake.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new<R, W, A>(
stream: Stream<R, W>,
signer: SecretKey,
attester: A,
) -> Self
pub fn new<R, W, A>( stream: Stream<R, W>, signer: SecretKey, attester: A, ) -> Self
Takes ownership of a stream and constructs its transport internally. The attester supplies the current device attestation for each handshake. Starts its persistent reader immediately. Failure to start a required worker or an escaping worker panic aborts the process.
Sourcepub fn set_abandonment_timeout(self, timeout: Duration) -> Self
pub fn set_abandonment_timeout(self, timeout: Duration) -> Self
Sets the lifetime of automatic UNANSWERED replies for the current and
future sessions. Defaults to DEFAULT_ABANDONMENT_TIMEOUT. Applies even
before accept(). Replies already queued keep their deadlines.
See Session::set_abandonment_timeout for when the timeout starts and
expires. Changing a session’s timeout leaves the server’s default unchanged.
This method also replaces a timeout set directly on the current session.
Sourcepub fn set_inbound_limits(self, requests: usize, bytes: usize) -> Self
pub fn set_inbound_limits(self, requests: usize, bytes: usize) -> Self
Sets both per-session inbound limits, initially
DEFAULT_MAX_INBOUND_REQUESTS and DEFAULT_MAX_INBOUND_BYTES.
Applies to the current session, even before accept(), and future sessions.
Lowering either limit below usage closes that session. The server stays open.
See Session::set_inbound_limits for what each limit counts. Changing a
session’s limits leaves the server’s defaults unchanged. This method also
replaces limits set directly on the current session.
Sourcepub fn accept(&mut self) -> Result<Session, Error>
pub fn accept(&mut self) -> Result<Session, Error>
Blocks until a session is established or the server ends. Recoverable handshake failures leave the stream available for another attempt. A replacement session closes the previous one; old handles still refer to it.
The reader runs before acceptance. A returned session may already have queued requests or be closed, including from exceeding an inbound limit. If several sessions arrive before acceptance, only the newest is returned.
Sourcepub fn closer(&self) -> Closer
pub fn closer(&self) -> Closer
Returns a clonable handle for closing this server from another thread,
including while its owner is blocked in Self::accept.