fn send_grease_frames(
        &mut self, conn: &mut super::Connection, stream_id: u64,
    ) -> Result<()> {
        let mut d = [0; 8];

        let stream_cap = match conn.stream_capacity(stream_id) {
            Ok(v) => v,

            Err(e) => {
                if conn.stream_finished(stream_id) {
                    self.streams.remove(&stream_id);
                }

                return Err(e.into());
            },
        };

        let grease_frame1 = grease_value();
        let grease_frame2 = grease_value();
        let grease_payload = b"GREASE is the word";

        let overhead = octets::varint_len(grease_frame1) + // frame type
            1 + // payload len
            octets::varint_len(grease_frame2) + // frame type
            1 + // payload len
            grease_payload.len(); // payload

        // Don't send GREASE if there is not enough capacity for it. Greasing
        // will _not_ be attempted again later on.
        if stream_cap < overhead {
            return Ok(());
        }

        // Empty GREASE frame.
        let mut b = octets::OctetsMut::with_slice(&mut d);
        conn.stream_send(stream_id, b.put_varint(grease_frame1)?, false)?;

        let mut b = octets::OctetsMut::with_slice(&mut d);
        conn.stream_send(stream_id, b.put_varint(0)?, false)?;

        trace!(
            "{} tx frm GREASE stream={} len=0",
            conn.trace_id(),
            stream_id
        );

        qlog_with_type!(QLOG_FRAME_CREATED, conn.qlog, q, {
            let frame = Http3Frame::Reserved { length: Some(0) };
            let ev_data = EventData::H3FrameCreated(H3FrameCreated {
                stream_id,
                length: Some(0),
                frame,
                raw: None,
            });

            q.add_event_data_now(ev_data).ok();
        });

        // GREASE frame with payload.
        let mut b = octets::OctetsMut::with_slice(&mut d);
        conn.stream_send(stream_id, b.put_varint(grease_frame2)?, false)?;

        let mut b = octets::OctetsMut::with_slice(&mut d);
        conn.stream_send(stream_id, b.put_varint(18)?, false)?;

        conn.stream_send(stream_id, grease_payload, false)?;

        trace!(
            "{} tx frm GREASE stream={} len={}",
            conn.trace_id(),
            stream_id,
            grease_payload.len()
        );

        qlog_with_type!(QLOG_FRAME_CREATED, conn.qlog, q, {
            let frame = Http3Frame::Reserved {
                length: Some(grease_payload.len() as u64),
            };
            let ev_data = EventData::H3FrameCreated(H3FrameCreated {
                stream_id,
                length: Some(grease_payload.len() as u64),
                frame,
                raw: None,
            });

            q.add_event_data_now(ev_data).ok();
        });

        Ok(())
    }
/// Send GREASE frames on the provided stream ID.
Send GREASE frames on the provided stream ID.
Send GREASE frames on the provided stream ID .
fn send_grease_frames(
        &mut self, conn: &mut super::Connection, stream_id: u64,
    ) -> Result<()> {
        let mut d = [0; 8];
        let stream_cap = match conn.stream_capacity(stream_id) {
            Ok(v) => v,
            Err(e) => {
                if conn.stream_finished(stream_id) {
                    self.streams.remove(&stream_id);
                }
                return Err(e.into());
            },
        };
        let grease_frame1 = grease_value();
        let grease_frame2 = grease_value();
        let grease_payload = b"GREASE is the word";
        let overhead = octets::varint_len(grease_frame1) + // frame type
            1 + // payload len
            octets::varint_len(grease_frame2) + // frame type
            1 + // payload len
            grease_payload.len(); // payload
        // Don't send GREASE if there is not enough capacity for it. Greasing
        // will _not_ be attempted again later on.
        if stream_cap < overhead {
            return Ok(());
        }
        // Empty GREASE frame.
        let mut b = octets::OctetsMut::with_slice(&mut d);
        conn.stream_send(stream_id, b.put_varint(grease_frame1)?, false)?;
        let mut b = octets::OctetsMut::with_slice(&mut d);
        conn.stream_send(stream_id, b.put_varint(0)?, false)?;
        trace!(
            "{} tx frm GREASE stream={} len=0",
            conn.trace_id(),
            stream_id
        );
        qlog_with_type!(QLOG_FRAME_CREATED, conn.qlog, q, {
            let frame = Http3Frame::Reserved { length: Some(0) };
            let ev_data = EventData::H3FrameCreated(H3FrameCreated {
                stream_id,
                length: Some(0),
                frame,
                raw: None,
            });
            q.add_event_data_now(ev_data).ok();
        });
        // GREASE frame with payload.
        let mut b = octets::OctetsMut::with_slice(&mut d);
        conn.stream_send(stream_id, b.put_varint(grease_frame2)?, false)?;
        let mut b = octets::OctetsMut::with_slice(&mut d);
        conn.stream_send(stream_id, b.put_varint(18)?, false)?;
        conn.stream_send(stream_id, grease_payload, false)?;
        trace!(
            "{} tx frm GREASE stream={} len={}",
            conn.trace_id(),
            stream_id,
            grease_payload.len()
        );
        qlog_with_type!(QLOG_FRAME_CREATED, conn.qlog, q, {
            let frame = Http3Frame::Reserved {
                length: Some(grease_payload.len() as u64),
            };
            let ev_data = EventData::H3FrameCreated(H3FrameCreated {
                stream_id,
                length: Some(grease_payload.len() as u64),
                frame,
                raw: None,
            });
            q.add_event_data_now(ev_data).ok();
        });
        Ok(())
    }
fn send_grease_frames ( & mut self , conn : & mut super :: Connection , stream_id : u64 , ) -> Result < ( ) > { let mut d = [ 0 ; 8 ] ; let stream_cap = match conn . stream_capacity ( stream_id ) { Ok ( v ) => v , Err ( e ) => { if conn . stream_finished ( stream_id ) { self . streams . remove ( & stream_id ) ; } return Err ( e . into ( ) ) ; } , } ; let grease_frame1 = grease_value ( ) ; let grease_frame2 = grease_value ( ) ; let grease_payload = b" " ; let overhead = octets :: varint_len ( grease_frame1 ) + // frame type 1 + // payload len octets :: varint_len ( grease_frame2 ) + // frame type 1 + // payload len grease_payload . len ( ) ; // payload // Don't send GREASE if there is not enough capacity for it. Greasing // will _not_ be attempted again later on. if stream_cap < overhead { return Ok ( ( ) ) ; } // Empty GREASE frame. let mut b = octets :: OctetsMut :: with_slice ( & mut d ) ; conn . stream_send ( stream_id , b . put_varint ( grease_frame1 ) ? , false ) ? ; let mut b = octets :: OctetsMut :: with_slice ( & mut d ) ; conn . stream_send ( stream_id , b . put_varint ( 0 ) ? , false ) ? ; trace ! ( " " conn trace_id ( ) stream_id ) ; qlog_with_type ! ( QLOG_FRAME_CREATED conn qlog q { let frame Http3Frame Reserved { length Some ( 0 ) } let ev_data EventData H3FrameCreated ( H3FrameCreated { stream_id length Some ( 0 ) frame raw None } ) q add_event_data_now ( ev_data ) ok ( ) } ) ; // GREASE frame with payload. let mut b = octets :: OctetsMut :: with_slice ( & mut d ) ; conn . stream_send ( stream_id , b . put_varint ( grease_frame2 ) ? , false ) ? ; let mut b = octets :: OctetsMut :: with_slice ( & mut d ) ; conn . stream_send ( stream_id , b . put_varint ( 18 ) ? , false ) ? ; conn . stream_send ( stream_id , grease_payload , false ) ? ; trace ! ( " " conn trace_id ( ) stream_id grease_payload len ( ) ) ; qlog_with_type ! ( QLOG_FRAME_CREATED conn qlog q { let frame Http3Frame Reserved { length Some ( grease_payload len ( ) as u64 ) } let ev_data EventData H3FrameCreated ( H3FrameCreated { stream_id length Some ( grease_payload len ( ) as u64 ) frame raw None } ) q add_event_data_now ( ev_data ) ok ( ) } ) ; Ok ( ( ) ) }
Send GREASE frames on the provided stream ID.
Send GREASE frames on the provided stream ID .
&mut self
conn
&mut super::Connection
stream_id
u64
&mut self
conn
&mut super::Connection
stream_id
u64