pub(crate) fn resize_stored_shred(mut shred: Vec<u8>) -> Result<Vec<u8>, Error> {
        let shred_type = match shred.get(OFFSET_OF_SHRED_TYPE) {
            None => return Err(Error::InvalidPayloadSize(shred.len())),
            Some(shred_type) => match ShredType::try_from(*shred_type) {
                Err(_) => return Err(Error::InvalidShredType),
                Ok(shred_type) => shred_type,
            },
        };
        match shred_type {
            ShredType::Code => {
                if shred.len() != SHRED_PAYLOAD_SIZE {
                    return Err(Error::InvalidPayloadSize(shred.len()));
                }
                Ok(shred)
            }
            ShredType::Data => {
                if !(SHRED_DATA_OFFSET..SHRED_PAYLOAD_SIZE).contains(&shred.len()) {
                    return Err(Error::InvalidPayloadSize(shred.len()));
                }
                shred.resize(SHRED_PAYLOAD_SIZE, 0u8);
                Ok(shred)
            }
        }
    }
// Possibly zero pads bytes stored in blockstore.
Possibly zero pads bytes stored in blockstore.
Possibly zero pads bytes stored in blockstore .
pub(crate) fn resize_stored_shred(mut shred: Vec<u8>) -> Result<Vec<u8>, Error> {
        let shred_type = match shred.get(OFFSET_OF_SHRED_TYPE) {
            None => return Err(Error::InvalidPayloadSize(shred.len())),
            Some(shred_type) => match ShredType::try_from(*shred_type) {
                Err(_) => return Err(Error::InvalidShredType),
                Ok(shred_type) => shred_type,
            },
        };
        match shred_type {
            ShredType::Code => {
                if shred.len() != SHRED_PAYLOAD_SIZE {
                    return Err(Error::InvalidPayloadSize(shred.len()));
                }
                Ok(shred)
            }
            ShredType::Data => {
                if !(SHRED_DATA_OFFSET..SHRED_PAYLOAD_SIZE).contains(&shred.len()) {
                    return Err(Error::InvalidPayloadSize(shred.len()));
                }
                shred.resize(SHRED_PAYLOAD_SIZE, 0u8);
                Ok(shred)
            }
        }
    }
pub ( crate ) fn resize_stored_shred ( mut shred : Vec < u8 > ) -> Result < Vec < u8 > , Error > { let shred_type = match shred . get ( OFFSET_OF_SHRED_TYPE ) { None => return Err ( Error :: InvalidPayloadSize ( shred . len ( ) ) ) , Some ( shred_type ) => match ShredType :: try_from ( * shred_type ) { Err ( _ ) => return Err ( Error :: InvalidShredType ) , Ok ( shred_type ) => shred_type , } , } ; match shred_type { ShredType :: Code => { if shred . len ( ) != SHRED_PAYLOAD_SIZE { return Err ( Error :: InvalidPayloadSize ( shred . len ( ) ) ) ; } Ok ( shred ) } ShredType :: Data => { if ! ( SHRED_DATA_OFFSET .. SHRED_PAYLOAD_SIZE ) . contains ( & shred . len ( ) ) { return Err ( Error :: InvalidPayloadSize ( shred . len ( ) ) ) ; } shred . resize ( SHRED_PAYLOAD_SIZE , 0u8 ) ; Ok ( shred ) } } }
Possibly zero pads bytes stored in blockstore.
Possibly zero pads bytes stored in blockstore .
shred
Vec<u8>
shred
Vec<u8>