#[non_exhaustive]pub struct Config {
pub limits: Limits,
pub max_pending: usize,
pub max_in_flight: usize,
pub request_timeout: Option<Duration>,
pub cancellation: Option<Cancellation>,
pub gate: Option<Gate>,
}Available on crate feature
std only.Expand description
An endpoint’s settings.
| Setting | Default | Meaning |
|---|---|---|
limits | Limits::new | budgets on incoming messages |
max_pending | 1024 | our requests awaiting answers; one more evicts the oldest |
max_in_flight | 1024 | deferred requests being answered; more are refused with SERVER_OVERLOADED |
request_timeout | none | deadline for our requests that set none themselves |
cancellation | Cancellation::lsp | the cancel notification, both ways; None turns cancellation off |
gate | none | an opening request every other request must wait for |
#[non_exhaustive]: start from Config::new and chain with_*.
§Examples
use std::time::Duration;
use rpc_io::{Cancellation, Config, Gate};
let lsp = Config::new()
.with_gate(Some(Gate::new("initialize").allow("exit")))
.with_request_timeout(Some(Duration::from_secs(30)));
let mcp = Config::new().with_cancellation(Some(Cancellation::mcp()));
assert_eq!(lsp.max_pending, 1024);
assert_eq!(mcp.cancellation.map(|c| c.id_member), Some("requestId".into()));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.limits: LimitsBudgets on incoming messages.
max_pending: usizeMost of our requests awaiting an answer at once (at least one).
max_in_flight: usizeMost deferred requests being answered at once.
request_timeout: Option<Duration>The deadline for our requests that do not set their own.
cancellation: Option<Cancellation>How cancellation is spelled, or None for none.
gate: Option<Gate>The opening request, if the protocol has one.
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_limits(self, limits: Limits) -> Self
pub fn with_limits(self, limits: Limits) -> Self
Sets limits.
§Examples
use rpc_io::{Config, Limits};
let c = Config::new().with_limits(Limits::new().with_max_batch(4));
assert_eq!(c.limits.max_batch, 4);Sourcepub fn with_max_pending(self, count: usize) -> Self
pub fn with_max_pending(self, count: usize) -> Self
Sourcepub fn with_max_in_flight(self, count: usize) -> Self
pub fn with_max_in_flight(self, count: usize) -> Self
Sets max_in_flight.
§Examples
assert_eq!(rpc_io::Config::new().with_max_in_flight(8).max_in_flight, 8);Sourcepub fn with_request_timeout(self, timeout: Option<Duration>) -> Self
pub fn with_request_timeout(self, timeout: Option<Duration>) -> Self
Sets request_timeout.
§Examples
use std::time::Duration;
let c = rpc_io::Config::new().with_request_timeout(Some(Duration::from_secs(5)));
assert_eq!(c.request_timeout, Some(Duration::from_secs(5)));Sourcepub fn with_cancellation(self, cancellation: Option<Cancellation>) -> Self
pub fn with_cancellation(self, cancellation: Option<Cancellation>) -> Self
Sets cancellation.
§Examples
assert!(rpc_io::Config::new().with_cancellation(None).cancellation.is_none());Trait Implementations§
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more