Function data_model::volatile_memory::calc_offset
source · pub fn calc_offset(base: usize, offset: usize) -> VolatileMemoryResult<usize>Expand description
Convenience function for computing base + offset which returns
Err(VolatileMemoryError::Overflow) instead of panicking in the case base + offset exceeds
u64::MAX.
Examples
let mem_end = calc_offset(offset, count)?;
if mem_end > 100 {
return Err(VolatileMemoryError::OutOfBounds{addr: mem_end});
}