/// Check if enough space exists in the given buffer to decode an element;
/// it will not actually call `decode` or try to construct an instance,
/// but EBML errors with the next tag header will be returned eagerly.
Check if enough space exists in the given buffer to decode an element;
it will not actually call `decode` or try to construct an instance,
but EBML errors with the next tag header will be returned eagerly.
Check if enough space exists in the given buffer to decode an element ; it will not actually call ` decode ` or try to construct an instance but EBML errors with the next tag header will be returned eagerly .
fn check_space(bytes: &[u8]) -> Result<Option<EbmlLayout>, EbmlError> {
        match decode_tag(bytes) {
            Ok(None) => Ok(None),
            Err(err) => Err(err),
            Ok(Some((element_id, payload_size_tag, body_offset))) => {
                let should_unwrap = Self::should_unwrap(element_id);
                let payload_size = match (should_unwrap, payload_size_tag) {
                    (true, _) => 0,
                    (false, Varint::Unknown) => return Err(EbmlError::UnknownElementLength),
                    (false, Varint::Value(size)) => size as usize
                };
                let element_len = body_offset + payload_size;
                if element_len > bytes.len() {
                    // need to read more still
                    Ok(None)
                } else {
                    Ok(Some(EbmlLayout {
                        element_id,
                        body_offset,
                        element_len
                    }))
                }
            }
        }
    }
fn check_space ( bytes : & [ u8 ] ) -> Result < Option < EbmlLayout > , EbmlError > { match decode_tag ( bytes ) { Ok ( None ) => Ok ( None ) , Err ( err ) => Err ( err ) , Ok ( Some ( ( element_id , payload_size_tag , body_offset ) ) ) => { let should_unwrap = Self :: should_unwrap ( element_id ) ; let payload_size = match ( should_unwrap , payload_size_tag ) { ( true , _ ) => 0 , ( false , Varint :: Unknown ) => return Err ( EbmlError :: UnknownElementLength ) , ( false , Varint :: Value ( size ) ) => size as usize } ; let element_len = body_offset + payload_size ; if element_len > bytes . len ( ) { // need to read more still Ok ( None ) } else { Ok ( Some ( EbmlLayout { element_id , body_offset , element_len } ) ) } } } }
Check if enough space exists in the given buffer to decode an element;
it will not actually call `decode` or try to construct an instance,
but EBML errors with the next tag header will be returned eagerly.
Check if enough space exists in the given buffer to decode an element ; it will not actually call ` decode ` or try to construct an instance but EBML errors with the next tag header will be returned eagerly .
bytes
&[u8]