Skip to main content

OversizedTransferConfig

Struct OversizedTransferConfig 

Source
#[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
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.
§enabled: bool

Master gate, true by default. When false the capability is neither advertised nor activated, and the server does not learn a client’s flag.

§threshold: usize

Serialized byte length at or above which the sender switches to oversized transfer.

§chunk_size: usize

Per-chunk data size (bytes).

§max_transfer_bytes: u64

Upper bound on the total reassembled payload a receiver will accept (bytes).

§max_transfer_chunks: u64

Upper bound on the number of chunks a receiver will accept.

§max_concurrent_transfers: usize

Upper bound on concurrently active receiver-side transfers.

§transfer_timeout_ms: u64

Hard timeout for an in-flight transfer (milliseconds), measured from admission. 0 disables the receiver-side watchdog.

§max_out_of_order_window: u64

Maximum forward gap between the next expected chunk and an out-of-order chunk that will still be buffered.

§max_out_of_order_chunks: usize

Maximum number of buffered out-of-order chunks.

§accept_timeout_ms: u64

Timeout 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

Source

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.

Source

pub fn with_enabled(self, enabled: bool) -> Self

Enable or disable oversized transfer.

Source

pub fn with_threshold(self, threshold: usize) -> Self

Set the serialized-byte threshold at which the sender fragments.

Source

pub fn with_chunk_size(self, chunk_size: usize) -> Self

Set the per-chunk data size (bytes).

Source

pub fn with_max_transfer_bytes(self, max: u64) -> Self

Set the upper bound on the total reassembled payload (bytes).

Source

pub fn with_max_transfer_chunks(self, max: u64) -> Self

Set the upper bound on the number of chunks a receiver will accept.

Source

pub fn with_max_concurrent_transfers(self, max: usize) -> Self

Set the upper bound on concurrently active receiver-side transfers.

Source

pub fn with_transfer_timeout_ms(self, ms: u64) -> Self

Set the hard per-transfer timeout (milliseconds).

Source

pub fn with_max_out_of_order_window(self, window: u64) -> Self

Set the maximum forward gap for buffering out-of-order chunks.

Source

pub fn with_max_out_of_order_chunks(self, max: usize) -> Self

Set the maximum number of buffered out-of-order chunks.

Source

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

Source§

fn clone(&self) -> OversizedTransferConfig

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 OversizedTransferConfig

Source§

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

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

impl Default for OversizedTransferConfig

Source§

fn default() -> Self

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

impl From<&OversizedTransferConfig> for TransferPolicy

Source§

fn from(config: &OversizedTransferConfig) -> Self

Project the receiver-relevant knobs of an OversizedTransferConfig into a TransferPolicy (the receiver admission policy).

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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