#[non_exhaustive]pub struct OversizedTransferConfig {
pub enabled: bool,
pub threshold: usize,
pub chunk_size: usize,
pub max_transfer_bytes: u64,
pub max_transfer_chunks: u64,
pub max_concurrent_transfers: usize,
pub transfer_timeout_ms: u64,
pub max_out_of_order_window: u64,
pub max_out_of_order_chunks: usize,
pub accept_timeout_ms: u64,
}Expand description
CEP-22 oversized-transfer configuration shared by both transports.
Bundles the capability gate plus the sender/receiver tuning knobs so the
nine numeric defaults don’t clutter the flat transport configs. Attached to
NostrServerTransportConfig
and NostrClientTransportConfig
via their with_oversized_transfer / with_oversized_enabled builders.
Enabled by default (TS parity) — opt out with
with_enabled(false) or the transports’
with_oversized_enabled(false) builders. The negotiation gates make the
default safe for non-oversized peers: the server activates only for
clients that advertise support, and the client fragments only requests
carrying a progressToken — a disabled peer just sees one extra
support_oversized_transfer tag.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.enabled: boolMaster gate, true by default. When false the capability is neither
advertised nor activated, and the server does not learn a client’s flag.
threshold: usizeSerialized byte length at or above which the sender switches to oversized transfer.
chunk_size: usizePer-chunk data size (bytes).
max_transfer_bytes: u64Upper bound on the total reassembled payload a receiver will accept (bytes).
max_transfer_chunks: u64Upper bound on the number of chunks a receiver will accept.
max_concurrent_transfers: usizeUpper bound on concurrently active receiver-side transfers.
transfer_timeout_ms: u64Hard timeout for an in-flight transfer (milliseconds), measured from
admission. 0 disables the receiver-side watchdog.
max_out_of_order_window: u64Maximum forward gap between the next expected chunk and an out-of-order chunk that will still be buffered.
max_out_of_order_chunks: usizeMaximum number of buffered out-of-order chunks.
accept_timeout_ms: u64Timeout a sender waits for an accept frame before giving up (milliseconds).
Used by the client transport only. The client is the sole party that
sends a start frame with an accept handshake and then waits for the
accept. On the server transport this field is inert: a server is
always the receiver of the handshake — it emits the accept, it never
waits for one — so its value is never read server-side.
Implementations§
Source§impl OversizedTransferConfig
impl OversizedTransferConfig
Sourcepub fn enabled() -> Self
pub fn enabled() -> Self
An explicitly enabled config with all other knobs at their defaults.
Redundant since enabled defaulted to true (kept for API
stability); equivalent to OversizedTransferConfig::default.
Sourcepub fn with_enabled(self, enabled: bool) -> Self
pub fn with_enabled(self, enabled: bool) -> Self
Enable or disable oversized transfer.
Sourcepub fn with_threshold(self, threshold: usize) -> Self
pub fn with_threshold(self, threshold: usize) -> Self
Set the serialized-byte threshold at which the sender fragments.
Sourcepub fn with_chunk_size(self, chunk_size: usize) -> Self
pub fn with_chunk_size(self, chunk_size: usize) -> Self
Set the per-chunk data size (bytes).
Sourcepub fn with_max_transfer_bytes(self, max: u64) -> Self
pub fn with_max_transfer_bytes(self, max: u64) -> Self
Set the upper bound on the total reassembled payload (bytes).
Sourcepub fn with_max_transfer_chunks(self, max: u64) -> Self
pub fn with_max_transfer_chunks(self, max: u64) -> Self
Set the upper bound on the number of chunks a receiver will accept.
Sourcepub fn with_max_concurrent_transfers(self, max: usize) -> Self
pub fn with_max_concurrent_transfers(self, max: usize) -> Self
Set the upper bound on concurrently active receiver-side transfers.
Sourcepub fn with_transfer_timeout_ms(self, ms: u64) -> Self
pub fn with_transfer_timeout_ms(self, ms: u64) -> Self
Set the hard per-transfer timeout (milliseconds).
Sourcepub fn with_max_out_of_order_window(self, window: u64) -> Self
pub fn with_max_out_of_order_window(self, window: u64) -> Self
Set the maximum forward gap for buffering out-of-order chunks.
Sourcepub fn with_max_out_of_order_chunks(self, max: usize) -> Self
pub fn with_max_out_of_order_chunks(self, max: usize) -> Self
Set the maximum number of buffered out-of-order chunks.
Sourcepub fn with_accept_timeout_ms(self, ms: u64) -> Self
pub fn with_accept_timeout_ms(self, ms: u64) -> Self
Set the sender’s accept-frame wait timeout (milliseconds).
Trait Implementations§
Source§impl Clone for OversizedTransferConfig
impl Clone for OversizedTransferConfig
Source§fn clone(&self) -> OversizedTransferConfig
fn clone(&self) -> OversizedTransferConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OversizedTransferConfig
impl Debug for OversizedTransferConfig
Source§impl Default for OversizedTransferConfig
impl Default for OversizedTransferConfig
Source§impl From<&OversizedTransferConfig> for TransferPolicy
impl From<&OversizedTransferConfig> for TransferPolicy
Source§fn from(config: &OversizedTransferConfig) -> Self
fn from(config: &OversizedTransferConfig) -> Self
Project the receiver-relevant knobs of an OversizedTransferConfig into
a TransferPolicy (the receiver admission policy).
Auto Trait Implementations§
impl Freeze for OversizedTransferConfig
impl RefUnwindSafe for OversizedTransferConfig
impl Send for OversizedTransferConfig
impl Sync for OversizedTransferConfig
impl Unpin for OversizedTransferConfig
impl UnsafeUnpin for OversizedTransferConfig
impl UnwindSafe for OversizedTransferConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more