Function nahpack::encode_block
[−]
[src]
pub fn encode_block<T: HpackEncodable>(
writer: &mut Vec<u8>,
block: &[T],
context: &mut HpackContext,
compress_threshold: usize
) -> usize
Encode an HTTP/2
header block to transmit in one or more HEADERS
, PUSH_PROMISE
, or
CONTINUATION
frames. The data written may be too large for one frame,
and the caller is responsible for splitting it.
Examples
use nahpack::{encode_block, HpackEncodable, HpackContext}; struct Header { name: &'static [u8], value: &'static [u8], is_compressable: bool, } impl HpackEncodable for Header { fn name(&self) -> &'static [u8] { self.name } fn value(&self) -> &'static [u8] { self.value } fn is_compressable(&self) -> bool { self.is_compressable.clone() } } let headers = vec![Header { name: b"name", value: b"value", is_compressable: true }, ]; let mut context = HpackContext::new(); let mut writer: Vec<u8> = Vec::new(); let bytes = encode_block(&mut writer, &headers, &mut context, 0);