Skip to main content

HostOptions

Struct HostOptions 

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

Host-side transport options, passed to host_with_options. HostOptions::default() is what host uses.

Implementations§

Source§

impl HostOptions

Source

pub fn new() -> Self

Source

pub fn max_pipe_instances(self, n: u32) -> Self

Cap on simultaneous instances of the Windows named pipe: live connections plus the one instance waiting for the next client. A client that arrives when the cap is reached gets “pipe busy” and retries, so a flood of connections cannot grow the host without bound. Default DEFAULT_MAX_PIPE_INSTANCES (16); clamped to 1..=254 (255 is “unlimited” to Win32 and is never used). Ignored on Unix, where there is no pipe.

Source

pub fn get_max_pipe_instances(&self) -> u32

The effective (clamped) cap.

Source

pub fn write_timeout(self, bound: Option<Duration>) -> Self

Longest one frame (hello, event, or response) may take to write and flush to a client. A client that stops reading fills the transport buffer and would otherwise block the writing thread, and the connection with it, forever; when the bound passes the host closes that connection (the client sees connection_closed, never a partial frame it could mistake for a reply), and the connection’s connection_closed handler hook runs. The bound is per frame, so a slow but progressing reader of a stream of events is not cut off unless a single frame stalls. Default DEFAULT_WRITE_TIMEOUT (120 s); None restores the earlier unbounded write. A zero duration is raised to 1 ms.

Source

pub fn get_write_timeout(&self) -> Option<Duration>

The effective write bound (None = unbounded).

Source

pub fn max_message(self, bytes: usize) -> Self

Largest message the host assembles from chunks, or hands out in chunks (see the chunk module). The frame limit (ServiceConfig::frame_limit) stays the cap on any one frame; this is the second, separate cap on a whole chunked request or result, held in memory per connection. Default 0: chunking is off, the host refuses rk.upload and never announces a chunked result (it was 256 MiB earlier in the unpublished 0.2.7; see issue #323). A service that takes large calls opts in with a size (see SUGGESTED_MAX_MESSAGE). A connection holds at most one assembly of at most this many bytes; the first piece is authorised before it is buffered, and the assembled text is bounded in nesting and value count before it is parsed.

Source

pub fn get_max_message(&self) -> usize

The effective message bound.

Source

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

Cap on simultaneous connections on Unix (the counterpart of the Windows pipe-instance cap, which this does not replace there): a connection that arrives over the cap is closed at once, before any frame is read, so a flood cannot grow the host’s threads and buffers without bound. Default DEFAULT_MAX_CONNECTIONS (64); at least 1. Unlike Windows “pipe busy”, the refused client sees the connection close rather than a retryable busy status. Ignored on Windows.

Source

pub fn get_max_connections(&self) -> usize

The effective connection cap.

Source

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

Connections the host admits beyond max_connections for the supervising owner only (see supervisor_pid). A host whose table is full of stalled or busy clients would otherwise close the supervisor’s own health probe and be judged dead while it is alive; these slots keep the probe able to connect. A connection from any other peer, or from the supervisor once every reserved slot is in use, is refused as before. Default DEFAULT_RESERVED_SLOTS (2); 0 reserves nothing. The peer’s pid only decides who may use the spare capacity: hello, the allowlist and the private secret still gate every connection. Ignored on Windows, where the pipe-instance cap bounds the table.

Source

pub fn get_reserved_slots(&self) -> usize

The effective number of reserved slots.

Source

pub fn supervisor_pid(self, pid: Option<u32>) -> Self

The process that may use the reserved slots: the kernel-reported pid of a connecting peer must equal it. Some(pid) names it, None lets nobody use them. When this is never called the supervisor is the host process’s parent, read when the host starts, which is the supervisor of a child it spawned (see the supervisor module). Ignored on Windows.

Source

pub fn get_supervisor_pid(&self) -> Option<u32>

The pid that may use the reserved slots, as the host would resolve it now. None when nobody may (or, off Unix, when there is no parent to name).

Source

pub fn handshake_timeout(self, bound: Option<Duration>) -> Self

Longest a new connection may take to complete hello. A connection that connects and then sends nothing (or too little) holds a table slot and a thread; when the bound passes the host closes it (the client sees the connection close) and records a ServiceEvent::ConnectionRejected with an empty app and the reason handshake deadline <n> ms passed. The bound ends when hello is accepted, so it never limits an established connection, whose frames are bounded by write_timeout and the client’s own deadline. Default DEFAULT_HANDSHAKE_TIMEOUT (5 s); None restores the earlier unbounded wait. A zero duration is raised to 1 ms. Applies on Unix and Windows.

Source

pub fn get_handshake_timeout(&self) -> Option<Duration>

The effective handshake bound (None = unbounded).

Trait Implementations§

Source§

impl Clone for HostOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for HostOptions

Source§

impl Debug for HostOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HostOptions

Source§

fn default() -> Self

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

impl Eq for HostOptions

Source§

impl PartialEq for HostOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HostOptions

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.