Struct stackdump_core::memory_region::SliceMemoryRegion
source · [−]pub struct SliceMemoryRegion<'a> { /* private fields */ }
Expand description
A memory region that is backed by a slice
Implementations
sourceimpl<'a> SliceMemoryRegion<'a>
impl<'a> SliceMemoryRegion<'a>
sourcepub fn new(data: &'a [u8]) -> Self
pub fn new(data: &'a [u8]) -> Self
Creates a new memory region starting at the given address with the given data
sourcepub fn bytes(&self) -> MemoryRegionIterator<'_>ⓘNotable traits for MemoryRegionIterator<'a>impl<'a> Iterator for MemoryRegionIterator<'a> type Item = u8;
pub fn bytes(&self) -> MemoryRegionIterator<'_>ⓘNotable traits for MemoryRegionIterator<'a>impl<'a> Iterator for MemoryRegionIterator<'a> type Item = u8;
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)
This function is especially unsafe. The memory region will reference the given data for its entire lifetime.
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)
You must not have another reference to this block of memory or any object that resides in this memory during the entire lifetime of the object
Trait Implementations
sourceimpl<'a> Clone for SliceMemoryRegion<'a>
impl<'a> Clone for SliceMemoryRegion<'a>
sourcefn clone(&self) -> SliceMemoryRegion<'a>
fn clone(&self) -> SliceMemoryRegion<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for SliceMemoryRegion<'a>
impl<'a> Debug for SliceMemoryRegion<'a>
sourceimpl<'a> Default for SliceMemoryRegion<'a>
impl<'a> Default for SliceMemoryRegion<'a>
sourcefn default() -> SliceMemoryRegion<'a>
fn default() -> SliceMemoryRegion<'a>
Returns the “default value” for a type. Read more
sourceimpl<'de: 'a, 'a> Deserialize<'de> for SliceMemoryRegion<'a>
impl<'de: 'a, 'a> Deserialize<'de> for SliceMemoryRegion<'a>
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'a> MemoryRegion for SliceMemoryRegion<'a>
impl<'a> MemoryRegion for SliceMemoryRegion<'a>
sourcefn read(&self, index: Range<u64>) -> Result<Option<Vec<u8>>, MemoryReadError>
fn read(&self, index: Range<u64>) -> Result<Option<Vec<u8>>, MemoryReadError>
Returns the slice of memory that can be found at the given address_range. If the given address range is not fully within the captured region, then None is returned. Read more
sourcefn read_u8(&self, address: u64) -> Result<Option<u8>, MemoryReadError>
fn read_u8(&self, address: u64) -> Result<Option<u8>, MemoryReadError>
Reads a byte from the given address if it is present in the region
sourcefn read_u32(
&self,
address: u64,
endianness: RunTimeEndian
) -> Result<Option<u32>, MemoryReadError>
fn read_u32(
&self,
address: u64,
endianness: RunTimeEndian
) -> Result<Option<u32>, MemoryReadError>
Reads a u32 from the given address if it is present in the region
sourceimpl<'a> PartialEq<SliceMemoryRegion<'a>> for SliceMemoryRegion<'a>
impl<'a> PartialEq<SliceMemoryRegion<'a>> for SliceMemoryRegion<'a>
sourcefn eq(&self, other: &SliceMemoryRegion<'a>) -> bool
fn eq(&self, other: &SliceMemoryRegion<'a>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SliceMemoryRegion<'a>) -> bool
fn ne(&self, other: &SliceMemoryRegion<'a>) -> bool
This method tests for !=
.
sourceimpl<'a> Serialize for SliceMemoryRegion<'a>
impl<'a> Serialize for SliceMemoryRegion<'a>
impl<'a> StructuralPartialEq for SliceMemoryRegion<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for SliceMemoryRegion<'a>
impl<'a> Send for SliceMemoryRegion<'a>
impl<'a> Sync for SliceMemoryRegion<'a>
impl<'a> Unpin for SliceMemoryRegion<'a>
impl<'a> UnwindSafe for SliceMemoryRegion<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more