Struct sozu_lib::network::buffer_queue::BufferQueue
[−]
[src]
pub struct BufferQueue { pub buffer_position: usize, pub parsed_position: usize, pub output_position: usize, pub start_parsing_position: usize, pub buffer: Buffer, pub input_queue: Vec<InputElement>, pub output_queue: Vec<OutputElement>, }
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
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
output_position: usize
start_parsing_position: usize
buffer: Buffer
input_queue: Vec<InputElement>
Vec<(start, length)>
output_queue: Vec<OutputElement>
Methods
impl BufferQueue
[src]
fn with_capacity(capacity: usize) -> BufferQueue
fn available_input_data(&self) -> usize
fn sliced_input(&mut self, count: usize)
fn spliced_input(&mut self, count: usize)
fn needs_input(&self) -> bool
fn can_restart_parsing(&self) -> bool
fn empty(&self) -> bool
fn merge_input_slices(&self) -> usize
fn input_data_size(&self) -> usize
fn unparsed_data(&self) -> &[u8]
fn consume_parsed_data(&mut self, size: usize)
should only be called with a count inferior to self.input_data_size()
fn slice_output(&mut self, count: usize)
fn delete_output(&mut self, count: usize)
fn splice_output(&mut self, count: usize)
fn insert_output(&mut self, v: Vec<u8>)
fn has_output_data(&self) -> bool
fn output_data_size(&self) -> usize
fn merge_output_slices(&self) -> usize
fn merge_output_deletes(&self) -> usize
fn next_output_data(&self) -> &[u8]
fn consume_output_data(&mut self, size: usize)
should only be called with a count inferior to self.input_data_size()
fn print_unparsed(&self)
fn print_and_consume_output(&mut self)
Trait Implementations
impl Debug for BufferQueue
[src]
impl PartialEq for BufferQueue
[src]
fn eq(&self, __arg_0: &BufferQueue) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BufferQueue) -> bool
This method tests for !=
.
impl Clone for BufferQueue
[src]
fn clone(&self) -> BufferQueue
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Write for BufferQueue
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Write
. Read more