pub fn block_bounds(offset: usize, length: usize, block_size: &BlockSize) 
            -> Result<BlockBounds, &'static str> {
        
        let block_size_in_bytes = block_size.block_size_in_bytes;
        if offset > block_size.size_in_bytes {
            return Err("offset was out of bounds");
        }
        let first_block = offset / block_size_in_bytes;
        let first_block_offset = offset % block_size_in_bytes;
        let last_block = core::cmp::min(
            block_size.size_in_blocks,
            (offset + length + block_size_in_bytes - 1) / block_size_in_bytes, // round up to next sector
        );
        let last_block_offset = (first_block_offset + length) % block_size_in_bytes;
        trace!("block_bounds: offset: {}, length: {}, first_block: {}, last_block: {}",
            offset, length, first_block, last_block
        );
        Ok(BlockBounds {
            range: first_block..last_block,
            first_block_offset,
            last_block_offset,
        })
    }
/// Calculates block-wise bounds based on a byte-wise offset and buffer length for some block based device.
/// 
/// # Arguments
/// * `offset`: the absolute byte offset from the beginning of the block storage device
///    at which the read/write starts.
/// * `length`: the number of bytes to be read/written.
/// * `block_size`: the relevant size information for the underlying block device.
/// 
/// # Return
/// Returns a `BlockBounds` object.
/// 
/// If `offset + length` extends past the bounds, the `Range` will be truncated
/// to the last block of the storage device (all the way to the end), 
/// and the `last_block_offset` will be `0`.
/// 
/// Returns an error if the `offset` extends past the bounds of this block device.
Calculates block-wise bounds based on a byte-wise offset and buffer length for some block based device.
Calculates block - wise bounds based on a byte - wise offset and buffer length for some block based device .
pub fn block_bounds(offset: usize, length: usize, block_size: &BlockSize) 
            -> Result<BlockBounds, &'static str> {
        let block_size_in_bytes = block_size.block_size_in_bytes;
        if offset > block_size.size_in_bytes {
            return Err("offset was out of bounds");
        }
        let first_block = offset / block_size_in_bytes;
        let first_block_offset = offset % block_size_in_bytes;
        let last_block = core::cmp::min(
            block_size.size_in_blocks,
            (offset + length + block_size_in_bytes - 1) / block_size_in_bytes, // round up to next sector
        );
        let last_block_offset = (first_block_offset + length) % block_size_in_bytes;
        trace!("block_bounds: offset: {}, length: {}, first_block: {}, last_block: {}",
            offset, length, first_block, last_block
        );
        Ok(BlockBounds {
            range: first_block..last_block,
            first_block_offset,
            last_block_offset,
        })
    }
pub fn block_bounds ( offset : usize , length : usize , block_size : & BlockSize ) -> Result < BlockBounds , & ' static str > { let block_size_in_bytes = block_size . block_size_in_bytes ; if offset > block_size . size_in_bytes { return Err ( " " ) ; } let first_block = offset / block_size_in_bytes ; let first_block_offset = offset % block_size_in_bytes ; let last_block = core :: cmp :: min ( block_size . size_in_blocks , ( offset + length + block_size_in_bytes - 1 ) / block_size_in_bytes , // round up to next sector ) ; let last_block_offset = ( first_block_offset + length ) % block_size_in_bytes ; trace ! ( " " offset length first_block last_block ) ; Ok ( BlockBounds { range : first_block .. last_block , first_block_offset , last_block_offset , } ) }
Calculates block-wise bounds based on a byte-wise offset and buffer length for some block based device.
Calculates block - wise bounds based on a byte - wise offset and buffer length for some block based device .
Returns a `BlockBounds` object.

If `offset + length` extends past the bounds, the `Range` will be truncated
to the last block of the storage device (all the way to the end),
and the `last_block_offset` will be `0`.

Returns an error if the `offset` extends past the bounds of this block device.
Returns a ` BlockBounds ` object . If ` offset + length ` extends past the bounds the ` Range ` will be truncated to the last block of the storage device ( all the way to the end ) and the ` last_block_offset ` will be ` 0 ` . Returns an error if the ` offset ` extends past the bounds of this block device .
offset
usize
length
usize
block_size
&BlockSize