pub struct StreamWindow {
pub stream_id: u64,
pub total_consumed: u64,
}Expand description
Receiver → sender credit grant. Authoritative: total_consumed
is the receiver’s cumulative bytes-consumed count on the named
stream since it was opened. The sender uses this to recompute
tx_credit_remaining = tx_window - (tx_bytes_sent - total_consumed),
making the mechanism self-healing against lost grants.
§Consumer-side validation
The codec accepts any total_consumed: u64. Pre-fix the doc-
comment’s “self-healing” framing implied no further validation
was needed, but the formula
tx_credit_remaining = tx_window - (tx_bytes_sent - total_consumed)
underflows if a malformed or hostile peer sends
total_consumed > tx_bytes_sent. The consumer MUST clamp
total_consumed to its local tx_bytes_sent watermark before
applying. StreamState::apply_authoritative_grant
(adapter/net/session.rs:1153-1154) does this today; any
future consumer of this codec must do the same. The codec
layer cannot do the clamp itself because it doesn’t know the
sender’s local state.
Fields§
§stream_id: u64Stream the grant applies to.
total_consumed: u64Receiver’s cumulative consumed-byte count on this stream.
Consumers MUST clamp this to the local tx_bytes_sent
watermark before deriving credit.
Implementations§
Trait Implementations§
Source§impl Clone for StreamWindow
impl Clone for StreamWindow
Source§fn clone(&self) -> StreamWindow
fn clone(&self) -> StreamWindow
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 StreamWindow
impl Debug for StreamWindow
Source§impl PartialEq for StreamWindow
impl PartialEq for StreamWindow
Source§fn eq(&self, other: &StreamWindow) -> bool
fn eq(&self, other: &StreamWindow) -> bool
self and other values to be equal, and is used by ==.impl Copy for StreamWindow
impl Eq for StreamWindow
impl StructuralPartialEq for StreamWindow
Auto Trait Implementations§
impl Freeze for StreamWindow
impl RefUnwindSafe for StreamWindow
impl Send for StreamWindow
impl Sync for StreamWindow
impl Unpin for StreamWindow
impl UnsafeUnpin for StreamWindow
impl UnwindSafe for StreamWindow
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.