pub fn send_and_insert(
        &mut self,
        conn: &mut Connection,
        name: &[u8],
        value: &[u8],
    ) -> Res<u64> {
        qdebug!([self], "insert {:?} {:?}.", name, value);

        let entry_size = name.len() + value.len() + ADDITIONAL_TABLE_ENTRY_SIZE;

        if !self.table.insert_possible(entry_size) {
            return Err(Error::DynamicTableFull);
        }

        let mut buf = QpackData::default();
        EncoderInstruction::InsertWithNameLiteral { name, value }
            .marshal(&mut buf, self.use_huffman);

        let stream_id = self.local_stream.stream_id().ok_or(Error::Internal)?;

        let sent = conn
            .stream_send_atomic(stream_id, &buf)
            .map_err(|e| map_stream_send_atomic_error(&e))?;
        if !sent {
            return Err(Error::EncoderStreamBlocked);
        }

        self.stats.dynamic_table_inserts += 1;

        match self.table.insert(name, value) {
            Ok(inx) => Ok(inx),
            Err(e) => {
                debug_assert!(false);
                Err(e)
            }
        }
    }
/// Inserts a new entry into a table and sends the corresponding instruction to a peer. An entry is added only
/// if it is possible to send the corresponding instruction immediately, i.e. the encoder stream is not
/// blocked by the flow control (or stream internal buffer(this is very unlikely)).
/// ### Errors
/// `EncoderStreamBlocked` if the encoder stream is blocked by the flow control.
/// `DynamicTableFull` if the dynamic table does not have enough space for the entry.
/// The function can return transport errors: `InvalidStreamId`, `InvalidInput` and `FinalSizeError`.
/// # Panics
/// When the insertion fails (it should not).
Inserts a new entry into a table and sends the corresponding instruction to a peer. An entry is added only
if it is possible to send the corresponding instruction immediately, i.e. the encoder stream is not
blocked by the flow control (or stream internal buffer(this is very unlikely)).
Inserts a new entry into a table and sends the corresponding instruction to a peer . An entry is added only if it is possible to send the corresponding instruction immediately i . e . the encoder stream is not blocked by the flow control ( or stream internal buffer ( this is very unlikely )) .
pub fn send_and_insert(
        &mut self,
        conn: &mut Connection,
        name: &[u8],
        value: &[u8],
    ) -> Res<u64> {
        qdebug!([self], "insert {:?} {:?}.", name, value);
        let entry_size = name.len() + value.len() + ADDITIONAL_TABLE_ENTRY_SIZE;
        if !self.table.insert_possible(entry_size) {
            return Err(Error::DynamicTableFull);
        }
        let mut buf = QpackData::default();
        EncoderInstruction::InsertWithNameLiteral { name, value }
            .marshal(&mut buf, self.use_huffman);
        let stream_id = self.local_stream.stream_id().ok_or(Error::Internal)?;
        let sent = conn
            .stream_send_atomic(stream_id, &buf)
            .map_err(|e| map_stream_send_atomic_error(&e))?;
        if !sent {
            return Err(Error::EncoderStreamBlocked);
        }
        self.stats.dynamic_table_inserts += 1;
        match self.table.insert(name, value) {
            Ok(inx) => Ok(inx),
            Err(e) => {
                debug_assert!(false);
                Err(e)
            }
        }
    }
pub fn send_and_insert ( & mut self , conn : & mut Connection , name : & [ u8 ] , value : & [ u8 ] , ) -> Res < u64 > { qdebug ! ( [ self ] " " name value ) ; let entry_size = name . len ( ) + value . len ( ) + ADDITIONAL_TABLE_ENTRY_SIZE ; if ! self . table . insert_possible ( entry_size ) { return Err ( Error :: DynamicTableFull ) ; } let mut buf = QpackData :: default ( ) ; EncoderInstruction :: InsertWithNameLiteral { name , value } . marshal ( & mut buf , self . use_huffman ) ; let stream_id = self . local_stream . stream_id ( ) . ok_or ( Error :: Internal ) ? ; let sent = conn . stream_send_atomic ( stream_id , & buf ) . map_err ( | e | map_stream_send_atomic_error ( & e ) ) ? ; if ! sent { return Err ( Error :: EncoderStreamBlocked ) ; } self . stats . dynamic_table_inserts += 1 ; match self . table . insert ( name , value ) { Ok ( inx ) => Ok ( inx ) , Err ( e ) => { debug_assert ! ( false ) ; Err ( e ) } } }
Inserts a new entry into a table and sends the corresponding instruction to a peer.
Inserts a new entry into a table and sends the corresponding instruction to a peer .
&mut self
conn
&mut Connection
name
&[u8]
value
&[u8]
errors
`EncoderStreamBlocked` if the encoder stream is blocked by the flow control.
`DynamicTableFull` if the dynamic table does not have enough space for the entry.
The function can return transport errors: `InvalidStreamId`, `InvalidInput` and `FinalSizeError`.
` EncoderStreamBlocked ` if the encoder stream is blocked by the flow control . ` DynamicTableFull ` if the dynamic table does not have enough space for the entry . The function can return transport errors : ` InvalidStreamId ` ` InvalidInput ` and ` FinalSizeError ` .
panics
When the insertion fails (it should not).
When the insertion fails ( it should not ) .