Struct stackdump_core::memory_region::VecMemoryRegion
source · pub struct VecMemoryRegion { /* private fields */ }
Expand description
A memory region that is backed by a stack allocated array
Implementations§
source§impl VecMemoryRegion
impl VecMemoryRegion
sourcepub fn new(start_address: u64, data: Vec<u8>) -> Self
pub fn new(start_address: u64, data: Vec<u8>) -> Self
Creates a new memory region starting at the given address with the given data
sourcepub fn bytes(&self) -> MemoryRegionIterator<'_> ⓘ
pub fn bytes(&self) -> MemoryRegionIterator<'_> ⓘ
Get a byte iterator for this region.
This iterator can be used to store the region as bytes or to stream over a network. The iterated bytes include the length so that if you use the FromIterator implementation, it consumes only the bytes that are part of the collection. This means you can chain multiple of these iterators after each other.
use arrayvec::ArrayVec;
use stackdump_core::memory_region::{ArrayMemoryRegion, MemoryRegion};
let region1 = ArrayMemoryRegion::<4>::new(0, ArrayVec::from([1, 2, 3, 4]));
let region2 = ArrayMemoryRegion::<4>::new(100, ArrayVec::from([5, 6, 7, 8]));
let mut intermediate_buffer = Vec::new();
intermediate_buffer.extend(region1.bytes());
intermediate_buffer.extend(region2.bytes());
let mut intermediate_iter = intermediate_buffer.iter();
assert_eq!(region1, ArrayMemoryRegion::<4>::from_iter(&mut intermediate_iter));
assert_eq!(region2, ArrayMemoryRegion::<4>::from_iter(&mut intermediate_iter));
sourcepub unsafe fn copy_from_memory(&mut self, data_ptr: *const u8, data_len: usize)
pub unsafe fn copy_from_memory(&mut self, data_ptr: *const u8, data_len: usize)
Clears the existing memory data and copies the new data from the given pointer
If the data_len is greater than the capacity of this memory region, then this function will panic.
Safety
The entire block of memory from data_ptr .. data_ptr + data_len
must be readable.
(A memcpy must be possible with the pointer as source)
Trait Implementations§
source§impl Clone for VecMemoryRegion
impl Clone for VecMemoryRegion
source§fn clone(&self) -> VecMemoryRegion
fn clone(&self) -> VecMemoryRegion
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for VecMemoryRegion
impl Debug for VecMemoryRegion
source§impl Default for VecMemoryRegion
impl Default for VecMemoryRegion
source§fn default() -> VecMemoryRegion
fn default() -> VecMemoryRegion
source§impl<'de> Deserialize<'de> for VecMemoryRegion
impl<'de> Deserialize<'de> for VecMemoryRegion
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<'a> FromIterator<&'a u8> for VecMemoryRegion
impl<'a> FromIterator<&'a u8> for VecMemoryRegion
source§impl FromIterator<u8> for VecMemoryRegion
impl FromIterator<u8> for VecMemoryRegion
source§impl MemoryRegion for VecMemoryRegion
impl MemoryRegion for VecMemoryRegion
source§fn read(&self, index: Range<u64>) -> Result<Option<Vec<u8>>, MemoryReadError>
fn read(&self, index: Range<u64>) -> Result<Option<Vec<u8>>, MemoryReadError>
source§fn read_u8(&self, address: u64) -> Result<Option<u8>, MemoryReadError>
fn read_u8(&self, address: u64) -> Result<Option<u8>, MemoryReadError>
source§fn read_u32(
&self,
address: u64,
endianness: RunTimeEndian
) -> Result<Option<u32>, MemoryReadError>
fn read_u32( &self, address: u64, endianness: RunTimeEndian ) -> Result<Option<u32>, MemoryReadError>
source§impl PartialEq<VecMemoryRegion> for VecMemoryRegion
impl PartialEq<VecMemoryRegion> for VecMemoryRegion
source§fn eq(&self, other: &VecMemoryRegion) -> bool
fn eq(&self, other: &VecMemoryRegion) -> bool
self
and other
values to be equal, and is used
by ==
.