fn erasure_block_index(&self) -> Option<usize> {
        let index = self.index().checked_sub(self.fec_set_index())?;
        let index = usize::try_from(index).ok()?;
        match self.shred_type() {
            ShredType::Data => Some(index),
            ShredType::Code => {
                // TODO should use first_coding_index once position field is
                // populated.
                // Assert that the last shred index in the erasure set does not
                // overshoot u32.
                self.fec_set_index().checked_add(u32::from(
                    self.coding_header
                        .num_data_shreds
                        .max(self.coding_header.num_coding_shreds)
                        .checked_sub(1)?,
                ))?;
                let num_data_shreds = usize::from(self.coding_header.num_data_shreds);
                let num_coding_shreds = usize::from(self.coding_header.num_coding_shreds);
                let fec_set_size = num_data_shreds.checked_add(num_coding_shreds)?;
                let index = index.checked_add(num_data_shreds)?;
                (index < fec_set_size).then(|| index)
            }
        }
    }
// Returns the block index within the erasure coding set.
Returns the block index within the erasure coding set.
Returns the block index within the erasure coding set .
fn erasure_block_index(&self) -> Option<usize> {
        let index = self.index().checked_sub(self.fec_set_index())?;
        let index = usize::try_from(index).ok()?;
        match self.shred_type() {
            ShredType::Data => Some(index),
            ShredType::Code => {
                // TODO should use first_coding_index once position field is
                // populated.
                // Assert that the last shred index in the erasure set does not
                // overshoot u32.
                self.fec_set_index().checked_add(u32::from(
                    self.coding_header
                        .num_data_shreds
                        .max(self.coding_header.num_coding_shreds)
                        .checked_sub(1)?,
                ))?;
                let num_data_shreds = usize::from(self.coding_header.num_data_shreds);
                let num_coding_shreds = usize::from(self.coding_header.num_coding_shreds);
                let fec_set_size = num_data_shreds.checked_add(num_coding_shreds)?;
                let index = index.checked_add(num_data_shreds)?;
                (index < fec_set_size).then(|| index)
            }
        }
    }
fn erasure_block_index ( & self ) -> Option < usize > { let index = self . index ( ) . checked_sub ( self . fec_set_index ( ) ) ? ; let index = usize :: try_from ( index ) . ok ( ) ? ; match self . shred_type ( ) { ShredType :: Data => Some ( index ) , ShredType :: Code => { // TODO should use first_coding_index once position field is // populated. // Assert that the last shred index in the erasure set does not // overshoot u32. self . fec_set_index ( ) . checked_add ( u32 :: from ( self . coding_header . num_data_shreds . max ( self . coding_header . num_coding_shreds ) . checked_sub ( 1 ) ? , ) ) ? ; let num_data_shreds = usize :: from ( self . coding_header . num_data_shreds ) ; let num_coding_shreds = usize :: from ( self . coding_header . num_coding_shreds ) ; let fec_set_size = num_data_shreds . checked_add ( num_coding_shreds ) ? ; let index = index . checked_add ( num_data_shreds ) ? ; ( index < fec_set_size ) . then ( | | index ) } } }
Returns the block index within the erasure coding set.
Returns the block index within the erasure coding set .
&self