Skip to main content

OpenNetConfig

Struct OpenNetConfig 

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

Internal runtime, queue capacities, and default network policy used when constructing crate::OpenNet. Queue capacities count pending tasks, not bytes or concurrency, default to 128, must be in 1..=tokio::sync::Semaphore::MAX_PERMITS, and are fixed after engine creation. crate::OpenNet::new_with_config validates them before creating channels or workers and reports invalid values as crate::error::ErrorKind::InvalidConfig. When ws-client is enabled, configure a provider in the nested NetworkConfig before constructing crate::OpenNet, unless the host application has already installed a process-wide rustls provider.

Implementations§

Source§

impl OpenNetConfig

Source

pub fn with_runtime_worker_threads(self, threads: usize) -> Self

Sets the management runtime worker count (1..=256). If omitted, Tokio defaults apply, including the TOKIO_WORKER_THREADS environment variable. The explicit value is validated before creation and does not cap per-client I/O, callback, management, or blocking threads.

use open_net::{NetError, OpenNet, OpenNetConfig};

#[cfg(feature = "ws-client")]
use open_net::network::{NetworkConfig, TlsConfig};
#[cfg(feature = "ws-client")]
use std::sync::Arc;
let config = OpenNetConfig::default().with_runtime_worker_threads(2);
#[cfg(feature = "ws-client")]
let config = config.with_network_config(
    NetworkConfig::default().with_tls(
        TlsConfig::default().with_crypto_provider(Arc::new(
            rustls_openssl::default_provider(),
        )),
    ),
);
let net = OpenNet::new_with_config(config)?;
Source

pub fn with_async_queue_capacity(self, capacity: usize) -> Self

Sets the asynchronous submission queue capacity (default: 128). The value is validated during engine creation and must be within the semaphore-supported range.

Source

pub fn with_sync_queue_capacity(self, capacity: usize) -> Self

Sets the synchronous-call queue capacity (default: 128). Synchronous means the caller waits for a result; the underlying channel is still MPSC. The value is validated during engine creation and must be within the semaphore-supported range.

Source

pub fn with_network_config(self, config: NetworkConfig) -> Self

Sets the default WebSocket network policy; clients may override it at creation.

Source

pub fn runtime_worker_threads(&self) -> Option<usize>

Returns the configured management-runtime worker count, if explicitly set.

Source

pub fn async_queue_capacity(&self) -> usize

Returns the bounded asynchronous submission queue capacity.

Source

pub fn sync_queue_capacity(&self) -> usize

Returns the bounded synchronous submission queue capacity.

Source

pub fn network_config(&self) -> &NetworkConfig

Returns the default WebSocket network policy used for new clients.

Source

pub fn validate(&self) -> Result<(), NetError>

Validates runtime worker, queue, and nested network configuration limits.

Trait Implementations§

Source§

impl Clone for OpenNetConfig

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 Debug for OpenNetConfig

Source§

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

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

impl Default for OpenNetConfig

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more