pub trait MemoryAccessorExt: MemoryAccessor {
Show 26 methods
// Provided methods
fn read_memory_to_slice(
&self,
addr: UserAddress,
bytes: &mut [u8],
) -> Result<(), Errno> { ... }
fn read_memory_to_vec(
&self,
addr: UserAddress,
len: usize,
) -> Result<Vec<u8>, Errno> { ... }
fn read_memory_partial_to_vec(
&self,
addr: UserAddress,
max_len: usize,
) -> Result<Vec<u8>, Errno> { ... }
fn read_memory_to_array<const N: usize>(
&self,
addr: UserAddress,
) -> Result<[u8; N], Errno> { ... }
fn read_buffer(&self, buffer: &UserBuffer) -> Result<Vec<u8>, Errno> { ... }
fn read_object<T: FromBytes>(&self, user: UserRef<T>) -> Result<T, Errno> { ... }
fn read_multi_arch_ptr<T64, T32>(
&self,
user: MultiArchUserRef<MultiArchUserRef<T64, T32>, MultiArchUserRef<T64, T32>>,
) -> Result<MultiArchUserRef<T64, T32>, Errno> { ... }
fn read_multi_arch_object<T, T64: FromBytes + TryInto<T>, T32: FromBytes + TryInto<T>>(
&self,
user: MappingMultiArchUserRef<T, T64, T32>,
) -> Result<T, Errno> { ... }
fn read_multi_arch_objects_to_vec<T, T64: FromBytes + TryInto<T>, T32: FromBytes + TryInto<T>>(
&self,
user: MappingMultiArchUserRef<T, T64, T32>,
len: usize,
) -> Result<Vec<T>, Errno> { ... }
fn read_object_partial<T: FromBytes>(
&self,
user: UserRef<T>,
partial_size: usize,
) -> Result<T, Errno> { ... }
fn read_objects<'a, T: FromBytes>(
&self,
user: UserRef<T>,
objects: &'a mut [MaybeUninit<T>],
) -> Result<&'a mut [T], Errno> { ... }
fn read_objects_to_slice<T: FromBytes>(
&self,
user: UserRef<T>,
objects: &mut [T],
) -> Result<(), Errno> { ... }
fn read_objects_to_vec<T: FromBytes>(
&self,
user: UserRef<T>,
len: usize,
) -> Result<Vec<T>, Errno> { ... }
fn read_objects_to_smallvec<T: Clone + FromBytes, const N: usize>(
&self,
user: UserRef<T>,
len: usize,
) -> Result<SmallVec<[T; N]>, Errno> { ... }
fn read_objects_to_array<T: Copy + FromBytes, const N: usize>(
&self,
user: UserRef<T>,
) -> Result<[T; N], Errno> { ... }
fn read_iovec<T: Copy + Eq + IntoBytes + FromBytes + Immutable + TryInto<usize>>(
&self,
iovec_addr: IOVecPtr,
iovec_count: UserValue<T>,
) -> Result<UserBuffers, Errno> { ... }
fn read_c_string_to_vec(
&self,
string: UserCString,
max_size: usize,
) -> Result<FsString, Errno> { ... }
fn read_path(&self, path: UserCString) -> Result<FsString, Errno> { ... }
fn read_path_if_non_null(
&self,
path: UserCString,
) -> Result<FsString, Errno> { ... }
fn read_nul_delimited_c_string_list(
&self,
start: UserAddress,
len: usize,
) -> Result<Vec<FsString>, Errno> { ... }
fn read_c_string<'a>(
&self,
string: UserCString,
buffer: &'a mut [MaybeUninit<u8>],
) -> Result<&'a FsStr, Errno> { ... }
fn read_c_string_if_non_null<'a>(
&self,
addr: UserCString,
buffer: &'a mut [MaybeUninit<u8>],
) -> Result<&'a FsStr, Errno> { ... }
fn write_object<T: IntoBytes + Immutable>(
&self,
user: UserRef<T>,
object: &T,
) -> Result<usize, Errno> { ... }
fn write_objects<T: IntoBytes + Immutable>(
&self,
user: UserRef<T>,
objects: &[T],
) -> Result<usize, Errno> { ... }
fn write_multi_arch_ptr<Addr, T64, T32>(
&self,
user: Addr,
object: MultiArchUserRef<T64, T32>,
) -> Result<usize, Errno>
where Addr: Into<UserAddress> { ... }
fn write_multi_arch_object<T, T64: IntoBytes + Immutable + TryFrom<T>, T32: IntoBytes + Immutable + TryFrom<T>>(
&self,
user: MappingMultiArchUserRef<T, T64, T32>,
object: T,
) -> Result<usize, Errno> { ... }
}Provided Methods§
Sourcefn read_memory_to_slice(
&self,
addr: UserAddress,
bytes: &mut [u8],
) -> Result<(), Errno>
fn read_memory_to_slice( &self, addr: UserAddress, bytes: &mut [u8], ) -> Result<(), Errno>
Reads exactly bytes.len() bytes of memory from addr into bytes.
In case of success, the number of bytes read will always be bytes.len().
Consider using MemoryAccessorExt::read_memory_to_* methods if you do not require control
over the allocation.
Sourcefn read_memory_to_vec(
&self,
addr: UserAddress,
len: usize,
) -> Result<Vec<u8>, Errno>
fn read_memory_to_vec( &self, addr: UserAddress, len: usize, ) -> Result<Vec<u8>, Errno>
Read exactly len bytes of memory, returning them as a a Vec.
Sourcefn read_memory_partial_to_vec(
&self,
addr: UserAddress,
max_len: usize,
) -> Result<Vec<u8>, Errno>
fn read_memory_partial_to_vec( &self, addr: UserAddress, max_len: usize, ) -> Result<Vec<u8>, Errno>
Read up to max_len bytes from addr, returning them as a Vec.
Sourcefn read_memory_to_array<const N: usize>(
&self,
addr: UserAddress,
) -> Result<[u8; N], Errno>
fn read_memory_to_array<const N: usize>( &self, addr: UserAddress, ) -> Result<[u8; N], Errno>
Read exactly N bytes from addr, returning them as an array.
Sourcefn read_buffer(&self, buffer: &UserBuffer) -> Result<Vec<u8>, Errno>
fn read_buffer(&self, buffer: &UserBuffer) -> Result<Vec<u8>, Errno>
Read the contents of buffer, returning them as a Vec.
Sourcefn read_object<T: FromBytes>(&self, user: UserRef<T>) -> Result<T, Errno>
fn read_object<T: FromBytes>(&self, user: UserRef<T>) -> Result<T, Errno>
Read an instance of T from user.
fn read_multi_arch_ptr<T64, T32>( &self, user: MultiArchUserRef<MultiArchUserRef<T64, T32>, MultiArchUserRef<T64, T32>>, ) -> Result<MultiArchUserRef<T64, T32>, Errno>
Sourcefn read_multi_arch_object<T, T64: FromBytes + TryInto<T>, T32: FromBytes + TryInto<T>>(
&self,
user: MappingMultiArchUserRef<T, T64, T32>,
) -> Result<T, Errno>
fn read_multi_arch_object<T, T64: FromBytes + TryInto<T>, T32: FromBytes + TryInto<T>>( &self, user: MappingMultiArchUserRef<T, T64, T32>, ) -> Result<T, Errno>
Read an instance of T64 from user where the object has a different representation in 32
and 64 bits.
Sourcefn read_multi_arch_objects_to_vec<T, T64: FromBytes + TryInto<T>, T32: FromBytes + TryInto<T>>(
&self,
user: MappingMultiArchUserRef<T, T64, T32>,
len: usize,
) -> Result<Vec<T>, Errno>
fn read_multi_arch_objects_to_vec<T, T64: FromBytes + TryInto<T>, T32: FromBytes + TryInto<T>>( &self, user: MappingMultiArchUserRef<T, T64, T32>, len: usize, ) -> Result<Vec<T>, Errno>
Read exactly len objects from user, returning them as a Vec.
Sourcefn read_object_partial<T: FromBytes>(
&self,
user: UserRef<T>,
partial_size: usize,
) -> Result<T, Errno>
fn read_object_partial<T: FromBytes>( &self, user: UserRef<T>, partial_size: usize, ) -> Result<T, Errno>
Reads the first partial bytes of an object, leaving any remainder 0-filled.
This is used for reading size-versioned structures where the user can specify an older version of the structure with a smaller size.
Returns EINVAL if the input size is larger than the object (assuming the input size is from the user who has specified something we don’t support).
Sourcefn read_objects<'a, T: FromBytes>(
&self,
user: UserRef<T>,
objects: &'a mut [MaybeUninit<T>],
) -> Result<&'a mut [T], Errno>
fn read_objects<'a, T: FromBytes>( &self, user: UserRef<T>, objects: &'a mut [MaybeUninit<T>], ) -> Result<&'a mut [T], Errno>
Read exactly objects.len() objects into objects from user.
Sourcefn read_objects_to_slice<T: FromBytes>(
&self,
user: UserRef<T>,
objects: &mut [T],
) -> Result<(), Errno>
fn read_objects_to_slice<T: FromBytes>( &self, user: UserRef<T>, objects: &mut [T], ) -> Result<(), Errno>
Read exactly objects.len() objects into objects from user.
Sourcefn read_objects_to_vec<T: FromBytes>(
&self,
user: UserRef<T>,
len: usize,
) -> Result<Vec<T>, Errno>
fn read_objects_to_vec<T: FromBytes>( &self, user: UserRef<T>, len: usize, ) -> Result<Vec<T>, Errno>
Read exactly len objects from user, returning them as a Vec.
Sourcefn read_objects_to_smallvec<T: Clone + FromBytes, const N: usize>(
&self,
user: UserRef<T>,
len: usize,
) -> Result<SmallVec<[T; N]>, Errno>
fn read_objects_to_smallvec<T: Clone + FromBytes, const N: usize>( &self, user: UserRef<T>, len: usize, ) -> Result<SmallVec<[T; N]>, Errno>
Read exactly len objects from user, returning them as a SmallVec.
Sourcefn read_objects_to_array<T: Copy + FromBytes, const N: usize>(
&self,
user: UserRef<T>,
) -> Result<[T; N], Errno>
fn read_objects_to_array<T: Copy + FromBytes, const N: usize>( &self, user: UserRef<T>, ) -> Result<[T; N], Errno>
Read exactly N objects from user, returning them as an array.
Sourcefn read_iovec<T: Copy + Eq + IntoBytes + FromBytes + Immutable + TryInto<usize>>(
&self,
iovec_addr: IOVecPtr,
iovec_count: UserValue<T>,
) -> Result<UserBuffers, Errno>
fn read_iovec<T: Copy + Eq + IntoBytes + FromBytes + Immutable + TryInto<usize>>( &self, iovec_addr: IOVecPtr, iovec_count: UserValue<T>, ) -> Result<UserBuffers, Errno>
Read exactly iovec_count UserBuffers from iovec_addr.
Fails if iovec_count is greater than UIO_MAXIOV.
Sourcefn read_c_string_to_vec(
&self,
string: UserCString,
max_size: usize,
) -> Result<FsString, Errno>
fn read_c_string_to_vec( &self, string: UserCString, max_size: usize, ) -> Result<FsString, Errno>
Read up to max_size bytes from string, stopping at the first discovered null byte and
returning the results as a Vec.
Sourcefn read_path(&self, path: UserCString) -> Result<FsString, Errno>
fn read_path(&self, path: UserCString) -> Result<FsString, Errno>
Read a path from path, returning it as a FsString.
A convenience function that enforces the path length limit.
Sourcefn read_path_if_non_null(&self, path: UserCString) -> Result<FsString, Errno>
fn read_path_if_non_null(&self, path: UserCString) -> Result<FsString, Errno>
Read a path from path, returning it as a FsString, if the path is non-null.
A convenience function that enforces the path length limit.
Sourcefn read_nul_delimited_c_string_list(
&self,
start: UserAddress,
len: usize,
) -> Result<Vec<FsString>, Errno>
fn read_nul_delimited_c_string_list( &self, start: UserAddress, len: usize, ) -> Result<Vec<FsString>, Errno>
Read len bytes from start and parse the region as null-delimited CStrings, for example
how argv is stored.
There can be an arbitrary number of null bytes in between start and end.
Sourcefn read_c_string<'a>(
&self,
string: UserCString,
buffer: &'a mut [MaybeUninit<u8>],
) -> Result<&'a FsStr, Errno>
fn read_c_string<'a>( &self, string: UserCString, buffer: &'a mut [MaybeUninit<u8>], ) -> Result<&'a FsStr, Errno>
Read up to buffer.len() bytes from string, stopping at the first discovered null byte
and returning the result as a slice that ends before that null.
Consider using read_c_string_to_vec if you do not require control over the allocation.
Sourcefn read_c_string_if_non_null<'a>(
&self,
addr: UserCString,
buffer: &'a mut [MaybeUninit<u8>],
) -> Result<&'a FsStr, Errno>
fn read_c_string_if_non_null<'a>( &self, addr: UserCString, buffer: &'a mut [MaybeUninit<u8>], ) -> Result<&'a FsStr, Errno>
Returns a default initialized string if addr is null, otherwise
behaves as read_c_string.
fn write_object<T: IntoBytes + Immutable>( &self, user: UserRef<T>, object: &T, ) -> Result<usize, Errno>
fn write_objects<T: IntoBytes + Immutable>( &self, user: UserRef<T>, objects: &[T], ) -> Result<usize, Errno>
fn write_multi_arch_ptr<Addr, T64, T32>(
&self,
user: Addr,
object: MultiArchUserRef<T64, T32>,
) -> Result<usize, Errno>where
Addr: Into<UserAddress>,
fn write_multi_arch_object<T, T64: IntoBytes + Immutable + TryFrom<T>, T32: IntoBytes + Immutable + TryFrom<T>>( &self, user: MappingMultiArchUserRef<T, T64, T32>, object: T, ) -> Result<usize, Errno>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.