Struct sozu_lib::buffer_queue::BufferQueue
source · pub struct BufferQueue {
pub buffer_position: usize,
pub parsed_position: usize,
pub start_parsing_position: usize,
pub buffer: Checkout,
pub input_queue: Vec<InputElement>,
pub output_queue: Vec<OutputElement>,
}
Expand description
The BufferQueue has two roles: holding incoming data, and indicating which data will go out. When new data arrives, it is added at the end of the internal buffer. This new data is then eventually parsed or handled in some way by external code. The external code then adds element to the queue, indicating what to do with the data:
- copy a subset of the input data (and advance if needed)
- insert external data, like a HTTP header
- splice out of the kernel some data that was spliced in
position is the index in the stream of data already handled. it corresponds to the beginning of available data in the Buffer a Slice(begin, end) would point to buffer.data()[begin-position..end-position] (in the easiest case)
unparsed_position is the index in the stream of data that was not parsed yet
The buffer’s available data may be smaller than end - begin
.
It can happen if the parser indicated we need to copy more data than is available,
like with a content length
should the buffer queue indicate how much data it needs?
Fields§
§buffer_position: usize
position of buffer start in stream
parsed_position: usize
§start_parsing_position: usize
§buffer: Checkout
§input_queue: Vec<InputElement>
Vec<(start, length)>
output_queue: Vec<OutputElement>
Implementations§
source§impl BufferQueue
impl BufferQueue
pub fn with_buffer(buffer: Checkout) -> BufferQueue ⓘ
pub fn invariant(&self)
pub fn available_input_data(&self) -> usize
pub fn sliced_input(&mut self, count: usize)
pub fn spliced_input(&mut self, count: usize)
pub fn needs_input(&self) -> bool
pub fn can_restart_parsing(&self) -> bool
pub fn empty(&self) -> bool
pub fn merge_input_slices(&self) -> usize
pub fn input_data_size(&self) -> usize
pub fn unparsed_data(&self) -> &[u8] ⓘ
sourcepub fn consume_parsed_data(&mut self, size: usize)
pub fn consume_parsed_data(&mut self, size: usize)
should only be called with a count inferior to self.input_data_size()
pub fn slice_output(&mut self, count: usize)
pub fn delete_output(&mut self, count: usize)
pub fn splice_output(&mut self, count: usize)
pub fn insert_output(&mut self, v: Vec<u8>)
pub fn has_output_data(&self) -> bool
pub fn output_data_size(&self) -> usize
pub fn merge_output_slices(&self) -> usize
pub fn merge_output_deletes(&self) -> usize
pub fn next_output_data(&self) -> &[u8] ⓘ
pub fn as_ioslice(&self) -> Vec<IoSlice<'_>> ⓘ
sourcepub fn consume_output_data(&mut self, size: usize)
pub fn consume_output_data(&mut self, size: usize)
should only be called with a count inferior to self.input_data_size()
pub fn print_unparsed(&self)
pub fn print_and_consume_output(&mut self)
Trait Implementations§
source§impl Debug for BufferQueue
impl Debug for BufferQueue
source§impl Write for BufferQueue
impl Write for BufferQueue
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)