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
impl OpenNetConfig
Sourcepub fn with_runtime_worker_threads(self, threads: usize) -> Self
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)?;Sourcepub fn with_async_queue_capacity(self, capacity: usize) -> Self
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.
Sourcepub fn with_sync_queue_capacity(self, capacity: usize) -> Self
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.
Sourcepub fn with_network_config(self, config: NetworkConfig) -> Self
pub fn with_network_config(self, config: NetworkConfig) -> Self
Sets the default WebSocket network policy; clients may override it at creation.
Sourcepub fn runtime_worker_threads(&self) -> Option<usize>
pub fn runtime_worker_threads(&self) -> Option<usize>
Returns the configured management-runtime worker count, if explicitly set.
Sourcepub fn async_queue_capacity(&self) -> usize
pub fn async_queue_capacity(&self) -> usize
Returns the bounded asynchronous submission queue capacity.
Sourcepub fn sync_queue_capacity(&self) -> usize
pub fn sync_queue_capacity(&self) -> usize
Returns the bounded synchronous submission queue capacity.
Sourcepub fn network_config(&self) -> &NetworkConfig
pub fn network_config(&self) -> &NetworkConfig
Returns the default WebSocket network policy used for new clients.