Trait StreamDataControl

Source
pub trait StreamDataControl {
    const TYPE: StreamType;

    // Required methods
    fn data_size(&self) -> usize;
    fn end_of_stream(&self) -> bool;

    // Provided methods
    fn all(&self) -> Option<Vec<u8>> { ... }
    fn get(&self, range: impl RangeBounds<usize>) -> Option<Vec<u8>> { ... }
    fn set(&self, range: impl RangeBounds<usize>, value: &[u8]) { ... }
    fn replace(&self, value: &[u8]) { ... }
    fn clear(&self) { ... }
    fn write_upstream(&self, data: &[u8]) { ... }
    fn write_downstream(&self, data: &[u8]) { ... }
}
Expand description

Defines functions to interact with stream data

Required Associated Constants§

Source

const TYPE: StreamType

Upstream or Downstream

Required Methods§

Source

fn data_size(&self) -> usize

Length of this chunk of data

Source

fn end_of_stream(&self) -> bool

If true, this will be the last downstream data for this context.

Provided Methods§

Source

fn all(&self) -> Option<Vec<u8>>

Get all data

Source

fn get(&self, range: impl RangeBounds<usize>) -> Option<Vec<u8>>

Get a range of data

Source

fn set(&self, range: impl RangeBounds<usize>, value: &[u8])

Replace a range of data with value.

Source

fn replace(&self, value: &[u8])

Replace the entire data with value

Source

fn clear(&self)

Clear the data

Source

fn write_upstream(&self, data: &[u8])

Writes data directly upstream, should be called from downstream context.

Source

fn write_downstream(&self, data: &[u8])

Writes data directly downstream, should be called from upstream context.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl StreamDataControl for DownstreamData

Source§

const TYPE: StreamType = StreamType::Downstream

Source§

impl StreamDataControl for UpstreamData

Source§

const TYPE: StreamType = StreamType::Upstream