kinesin_rdt::stream::inbound

Struct StreamInboundState

Source
pub struct StreamInboundState {
    pub buffer: RingBuf<u8>,
    pub buffer_offset: u64,
    pub received: RangeSet,
    pub message_offsets: BTreeMap<u64, Option<u32>>,
    pub is_reliable: bool,
    pub window_limit: u64,
    pub final_offset: Option<u64>,
}
Expand description

stream inbound buffer

Fields§

§buffer: RingBuf<u8>

buffer for received data

§buffer_offset: u64

stream offset at which buffer starts

§received: RangeSet

received segments

§message_offsets: BTreeMap<u64, Option<u32>>

offsets into the stream where messages begin, if applicable

§is_reliable: bool

whether stream is operating in reliable mode

§window_limit: u64

flow control limit

§final_offset: Option<u64>

final length of stream (offset of final byte + 1)

Implementations§

Source§

impl StreamInboundState

Source

pub fn new(initial_window_limit: u64, is_reliable: bool) -> StreamInboundState

create new instance

Source

pub fn receive_segment( &mut self, offset: u64, data: &[u8], ) -> ReceiveSegmentResult

process incoming segment

Source

pub fn set_limit(&mut self, new_limit: u64)

advance window limit

Source

pub fn set_message_marker(&mut self, offset: u64)

set message marker at offset

Source

pub fn set_final_offset(&mut self, offset: u64) -> bool

set final offset from sender

Source

pub fn advance_buffer(&mut self, new_base: u64)

advance buffer, discarding data lower than the new base offset

Source

pub fn read_segment(&self, segment: Range<u64>) -> Option<RingBufSlice<'_, u8>>

read segment from buffer, if available

Source

pub fn max_contiguous_offset(&self) -> Option<u64>

return the highest offset into the stream for which no gaps exist between it and buffer_offset

Source

pub fn read_next(&self, limit: usize) -> Option<RingBufSlice<'_, u8>>

read available bytes from start of buffer

Only really makes sense when is_reliable = true.

Source

pub fn finished(&self) -> bool

check if stream is fully received

If unreliable, will return true as soon as a final offset is received, even if more segments are in transit.

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> 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, 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<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