Struct sozu_lib::network::buffer_queue::BufferQueue [−][src]
pub struct BufferQueue {
pub buffer_position: usize,
pub parsed_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] (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: Buffer
input_queue: Vec<InputElement>
Vec<(start, length)>
output_queue: Vec<OutputElement>
Methods
impl BufferQueue[src]
impl BufferQueueⓘImportant traits for BufferQueuepub fn with_capacity(capacity: usize) -> BufferQueue[src]
pub fn with_capacity(capacity: usize) -> BufferQueuepub fn invariant(&self)[src]
pub fn invariant(&self)pub fn available_input_data(&self) -> usize[src]
pub fn available_input_data(&self) -> usizepub fn sliced_input(&mut self, count: usize)[src]
pub fn sliced_input(&mut self, count: usize)pub fn spliced_input(&mut self, count: usize)[src]
pub fn spliced_input(&mut self, count: usize)pub fn needs_input(&self) -> bool[src]
pub fn needs_input(&self) -> boolpub fn can_restart_parsing(&self) -> bool[src]
pub fn can_restart_parsing(&self) -> boolpub fn empty(&self) -> bool[src]
pub fn empty(&self) -> boolpub fn merge_input_slices(&self) -> usize[src]
pub fn merge_input_slices(&self) -> usizepub fn input_data_size(&self) -> usize[src]
pub fn input_data_size(&self) -> usizepub fn unparsed_data(&self) -> &[u8][src]
pub fn unparsed_data(&self) -> &[u8]pub fn consume_parsed_data(&mut self, size: usize)[src]
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)[src]
pub fn slice_output(&mut self, count: usize)pub fn delete_output(&mut self, count: usize)[src]
pub fn delete_output(&mut self, count: usize)pub fn splice_output(&mut self, count: usize)[src]
pub fn splice_output(&mut self, count: usize)pub fn insert_output(&mut self, v: Vec<u8>)[src]
pub fn insert_output(&mut self, v: Vec<u8>)pub fn has_output_data(&self) -> bool[src]
pub fn has_output_data(&self) -> boolpub fn output_data_size(&self) -> usize[src]
pub fn output_data_size(&self) -> usizepub fn merge_output_slices(&self) -> usize[src]
pub fn merge_output_slices(&self) -> usizepub fn merge_output_deletes(&self) -> usize[src]
pub fn merge_output_deletes(&self) -> usizepub fn next_output_data(&self) -> &[u8][src]
pub fn next_output_data(&self) -> &[u8]pub fn consume_output_data(&mut self, size: usize)[src]
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)[src]
pub fn print_unparsed(&self)pub fn print_and_consume_output(&mut self)[src]
pub fn print_and_consume_output(&mut self)Trait Implementations
impl Debug for BufferQueue[src]
impl Debug for BufferQueuefn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl PartialEq for BufferQueue[src]
impl PartialEq for BufferQueuefn eq(&self, other: &BufferQueue) -> bool[src]
fn eq(&self, other: &BufferQueue) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &BufferQueue) -> bool[src]
fn ne(&self, other: &BufferQueue) -> boolThis method tests for !=.
impl Clone for BufferQueue[src]
impl Clone for BufferQueueⓘImportant traits for BufferQueuefn clone(&self) -> BufferQueue[src]
fn clone(&self) -> BufferQueueReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Write for BufferQueue[src]
impl Write for BufferQueuefn write(&mut self, buf: &[u8]) -> Result<usize>[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<()>[src]
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[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self1.0.0[src]
fn by_ref(&mut self) -> &mut SelfCreates a "by reference" adaptor for this instance of Write. Read more
impl Reset for BufferQueue[src]
impl Reset for BufferQueueAuto Trait Implementations
impl Send for BufferQueue
impl Send for BufferQueueimpl Sync for BufferQueue
impl Sync for BufferQueue