pub fn load(head: Head, mut src: BytesMut) -> Result<(Self, BytesMut), Error> {
        let flags = HeadersFlag(head.flag());
        let mut pad = 0;

        log::trace!("loading headers; flags={:?}", flags);

        // Read the padding length
        if flags.is_padded() {
            if src.is_empty() {
                return Err(Error::MalformedMessage);
            }
            pad = src[0] as usize;

            // Drop the padding
            let _ = src.split_to(1);
        }

        // Read the stream dependency
        let stream_dep = if flags.is_priority() {
            if src.len() < 5 {
                return Err(Error::MalformedMessage);
            }
            let stream_dep = StreamDependency::load(&src[..5])?;

            if stream_dep.dependency_id() == head.stream_id() {
                return Err(Error::InvalidDependencyId);
            }

            // Drop the next 5 bytes
            let _ = src.split_to(5);

            Some(stream_dep)
        } else {
            None
        };

        if pad > 0 {
            if pad > src.len() {
                return Err(Error::TooMuchPadding);
            }

            let len = src.len() - pad;
            src.truncate(len);
        }

        let headers = Headers {
            stream_id: head.stream_id(),
            stream_dep,
            header_block: HeaderBlock {
                fields: HeaderMap::new(),
                is_over_size: false,
                pseudo: Pseudo::default(),
            },
            flags,
        };

        Ok((headers, src))
    }
/// Loads the header frame but doesn't actually do HPACK decoding.
///
/// HPACK decoding is done in the `load_hpack` step.
Loads the header frame but doesn't actually do HPACK decoding.
HPACK decoding is done in the `load_hpack` step.
Loads the header frame but doesn ' t actually do HPACK decoding . HPACK decoding is done in the ` load_hpack ` step .
pub fn load(head: Head, mut src: BytesMut) -> Result<(Self, BytesMut), Error> {
        let flags = HeadersFlag(head.flag());
        let mut pad = 0;
        log::trace!("loading headers; flags={:?}", flags);
        // Read the padding length
        if flags.is_padded() {
            if src.is_empty() {
                return Err(Error::MalformedMessage);
            }
            pad = src[0] as usize;
            // Drop the padding
            let _ = src.split_to(1);
        }
        // Read the stream dependency
        let stream_dep = if flags.is_priority() {
            if src.len() < 5 {
                return Err(Error::MalformedMessage);
            }
            let stream_dep = StreamDependency::load(&src[..5])?;
            if stream_dep.dependency_id() == head.stream_id() {
                return Err(Error::InvalidDependencyId);
            }
            // Drop the next 5 bytes
            let _ = src.split_to(5);
            Some(stream_dep)
        } else {
            None
        };
        if pad > 0 {
            if pad > src.len() {
                return Err(Error::TooMuchPadding);
            }
            let len = src.len() - pad;
            src.truncate(len);
        }
        let headers = Headers {
            stream_id: head.stream_id(),
            stream_dep,
            header_block: HeaderBlock {
                fields: HeaderMap::new(),
                is_over_size: false,
                pseudo: Pseudo::default(),
            },
            flags,
        };
        Ok((headers, src))
    }
pub fn load ( head : Head , mut src : BytesMut ) -> Result < ( Self , BytesMut ) , Error > { let flags = HeadersFlag ( head . flag ( ) ) ; let mut pad = 0 ; log :: trace ! ( " " flags ) ; // Read the padding length if flags . is_padded ( ) { if src . is_empty ( ) { return Err ( Error :: MalformedMessage ) ; } pad = src [ 0 ] as usize ; // Drop the padding let _ = src . split_to ( 1 ) ; } // Read the stream dependency let stream_dep = if flags . is_priority ( ) { if src . len ( ) < 5 { return Err ( Error :: MalformedMessage ) ; } let stream_dep = StreamDependency :: load ( & src [ .. 5 ] ) ? ; if stream_dep . dependency_id ( ) == head . stream_id ( ) { return Err ( Error :: InvalidDependencyId ) ; } // Drop the next 5 bytes let _ = src . split_to ( 5 ) ; Some ( stream_dep ) } else { None } ; if pad > 0 { if pad > src . len ( ) { return Err ( Error :: TooMuchPadding ) ; } let len = src . len ( ) - pad ; src . truncate ( len ) ; } let headers = Headers { stream_id : head . stream_id ( ) , stream_dep , header_block : HeaderBlock { fields : HeaderMap :: new ( ) , is_over_size : false , pseudo : Pseudo :: default ( ) , } , flags , } ; Ok ( ( headers , src ) ) }
Loads the header frame but doesn't actually do HPACK decoding.
Loads the header frame but doesn ' t actually do HPACK decoding .
head
Head
src
BytesMut