pub struct StreamOutboundState {
pub buffer: RingBuf<u8>,
pub buffer_offset: u64,
pub buffer_limit: usize,
pub queued: RangeSet,
pub delivered: RangeSet,
pub message_offsets: BTreeSet<u64>,
pub is_initial_window: bool,
pub window_limit: u64,
pub retransmit_strategy: RetransmitStrategy,
pub final_offset: Option<u64>,
}
Expand description
stream outbound delivery
Fields§
§buffer: RingBuf<u8>
buffer for outbound data
buffer_offset: u64
stream offset at which buffer starts
buffer_limit: usize
outbound buffer size limit
queued: RangeSet
segments queued for (re)transmission
delivered: RangeSet
segments successfully delivered (retransmission unnecessary)
message_offsets: BTreeSet<u64>
offsets into the stream where messages begin, if applicable
is_initial_window: bool
if we’re still in the initial state (window limit not received yet)
window_limit: u64
peer inbound flow control receive limit
retransmit_strategy: RetransmitStrategy
retransmission strategy on packet loss
It is not currently supported to change this after construction.
final_offset: Option<u64>
final length of stream (offset of final byte + 1)
Implementations§
Source§impl StreamOutboundState
impl StreamOutboundState
pub fn new( initial_window_limit: u64, retransmit_strategy: RetransmitStrategy, ) -> StreamOutboundState
Sourcepub fn finished(&self) -> bool
pub fn finished(&self) -> bool
whether stream has delivered all segments
Will return true if a final offset is set and all segments prior to that offset have been delivered. In the case of the unreliable retransmit mode, segments are considered delivered as soon as they are sent. In the deadline transmission mode, segments prior to the deadline are considered delivered even if they have not been acknowledged.
Sourcepub fn update_remote_limit(&mut self, limit: u64) -> bool
pub fn update_remote_limit(&mut self, limit: u64) -> bool
remote window limit update received
Sourcepub fn write_direct(&mut self, buf: &[u8]) -> Range<u64>
pub fn write_direct(&mut self, buf: &[u8]) -> Range<u64>
write segment to stream, bypassing all restrictions
Sourcepub fn write_limited(&mut self, buf: &[u8]) -> usize
pub fn write_limited(&mut self, buf: &[u8]) -> usize
write segment to stream, respecting window and buffer limit
Sourcepub fn set_message_marker(&mut self, offset: u64)
pub fn set_message_marker(&mut self, offset: u64)
set message marker at offset
Sourcepub fn update_deadline(&mut self, new_limit: u64)
pub fn update_deadline(&mut self, new_limit: u64)
update deadline retransmission offset lower bound
Sourcepub fn advance_buffer(&mut self, new_base: u64)
pub fn advance_buffer(&mut self, new_base: u64)
advance buffer, discarding data lower than the new base
Sourcepub fn try_advance_buffer(&mut self)
pub fn try_advance_buffer(&mut self)
advance buffer if necessary
Sourcepub fn next_segment(&mut self, data_size_limit: usize) -> Option<Range<u64>>
pub fn next_segment(&mut self, data_size_limit: usize) -> Option<Range<u64>>
get next queued segment
Sourcepub fn read_segment(
&self,
segment: Range<u64>,
) -> Option<(RingBufSlice<'_, u8>, Option<u64>)>
pub fn read_segment( &self, segment: Range<u64>, ) -> Option<(RingBufSlice<'_, u8>, Option<u64>)>
get reference to bytes in segment, or none if out of range
Will return slice and first message marker in range, if one exists.
Sourcepub fn segment_sent(&mut self, segment: Range<u64>)
pub fn segment_sent(&mut self, segment: Range<u64>)
mark segment as sent
Sourcepub fn segment_lost(&mut self, segment: Range<u64>)
pub fn segment_lost(&mut self, segment: Range<u64>)
mark segment as lost
Sourcepub fn segment_delivered(&mut self, segment: Range<u64>)
pub fn segment_delivered(&mut self, segment: Range<u64>)
mark segment as delivered