pub struct LocalUser<T> {
pub(super) ptr: T,
}full only.Fields§
§ptr: TImplementations§
Source§impl<T: ?Sized> LocalUser<*const T>
impl<T: ?Sized> LocalUser<*const T>
Sourcepub unsafe fn new(addr: usize) -> Selfwhere
T: Sized,
pub unsafe fn new(addr: usize) -> Selfwhere
T: Sized,
Creates a new LocalUser<*const T> with tied to the current address space
§Safety
addr, if valid, must point to a valid bit pattern for T in the current address space.
This means that in almost all cases, it is unsound to create a LocalUser<*const T> where T
has a niche.
For all types with no invalid bit-patterns (i.e. all numeric types) it is sound to create
a LocalUser<*const T>.
Sourcepub const unsafe fn offset(self, count: isize) -> Selfwhere
T: Sized,
pub const unsafe fn offset(self, count: isize) -> Selfwhere
T: Sized,
Adds a signed offset to a pointer.
count is in units of T; e.g., a count of 3 represents a pointer
offset of 3 * size_of::<T>() bytes.
§Safety
See safety requirements for [<*const T>::offset()]
Sourcepub const unsafe fn byte_offset(self, count: isize) -> Self
pub const unsafe fn byte_offset(self, count: isize) -> Self
Adds a signed offset in bytes to a pointer.
§Safety
See safety requirements for [<*const T>::byte_offset()]
Sourcepub const unsafe fn add(self, count: usize) -> Selfwhere
T: Sized,
pub const unsafe fn add(self, count: usize) -> Selfwhere
T: Sized,
Adds an offset to a pointer.
count is in units of T; e.g., a count of 3 represents a pointer
offset of 3 * size_of::<T>() bytes.
§Safety
See safety requirements for [<*const T>::add()]
Sourcepub const unsafe fn sub(self, count: usize) -> Selfwhere
T: Sized,
pub const unsafe fn sub(self, count: usize) -> Selfwhere
T: Sized,
Subtracts an offset from a pointer.
count is in units of T; e.g., a count of 3 represents a pointer
offset of 3 * size_of::<T>() bytes.
§Safety
See safety requirements for [<*const T>::sub()]
Sourcepub const unsafe fn byte_sub(self, count: usize) -> Self
pub const unsafe fn byte_sub(self, count: usize) -> Self
Subtracts an offset in bytes from a pointer.
§Safety
See safety requirements for [<*const T>::byte_sub()]
Sourcepub fn read(self) -> Result<T, PointerError>where
T: Sized + Copy,
pub fn read(self) -> Result<T, PointerError>where
T: Sized + Copy,
Tries to read the value pointed to by the pointer
§Errors
If the pointer is invalid due to unmapped memory or similar, returns PointerError
Sourcepub const unsafe fn cast<U>(self) -> LocalUser<*const U>
pub const unsafe fn cast<U>(self) -> LocalUser<*const U>
Casts a pointer to another type
§Safety
If self has a valid address, then it must point to a valid bit pattern for U in the current
address space.
This means that in almost all cases, it is unsound to cast to a LocalUser<*const U> where U
has a niche.
For all types with no invalid bit-patterns (i.e. all numeric types) it is sound to cast to
a User<*const U>.
pub fn is_aligned_to(self, align: usize) -> bool
pub fn addr(self) -> VirtualAddress
pub fn align_offset(self, align: usize) -> usizewhere
T: Sized,
Source§impl<T: ?Sized> LocalUser<*mut T>
impl<T: ?Sized> LocalUser<*mut T>
Sourcepub fn new(addr: usize) -> Selfwhere
T: Sized,
pub fn new(addr: usize) -> Selfwhere
T: Sized,
Creates a new LocalUser<*mut T> with the provided address tied to the current address space
Sourcepub const unsafe fn offset(self, count: isize) -> Selfwhere
T: Sized,
pub const unsafe fn offset(self, count: isize) -> Selfwhere
T: Sized,
Adds a signed offset to a pointer.
count is in units of T; e.g., a count of 3 represents a pointer
offset of 3 * size_of::<T>() bytes.
§Safety
See safety requirements for [<*mut T>::offset()]
Sourcepub const unsafe fn byte_offset(self, count: isize) -> Self
pub const unsafe fn byte_offset(self, count: isize) -> Self
Adds a signed offset in bytes to a pointer.
§Safety
See safety requirements for [<*mut T>::byte_offset()]
Sourcepub const unsafe fn add(self, count: usize) -> Selfwhere
T: Sized,
pub const unsafe fn add(self, count: usize) -> Selfwhere
T: Sized,
Adds an offset to a pointer.
count is in units of T; e.g., a count of 3 represents a pointer
offset of 3 * size_of::<T>() bytes.
§Safety
See safety requirements for [<*mut T>::add()]
Sourcepub const unsafe fn sub(self, count: usize) -> Selfwhere
T: Sized,
pub const unsafe fn sub(self, count: usize) -> Selfwhere
T: Sized,
Subtracts an offset from a pointer.
count is in units of T; e.g., a count of 3 represents a pointer
offset of 3 * size_of::<T>() bytes.
§Safety
See safety requirements for [<*mut T>::sub()]
Sourcepub const unsafe fn byte_sub(self, count: usize) -> Self
pub const unsafe fn byte_sub(self, count: usize) -> Self
Subtracts an offset in bytes from a pointer.
§Safety
See safety requirements for [<*mut T>::byte_sub()]
Sourcepub fn write(self, value: T) -> Result<(), PointerError>where
T: Sized,
pub fn write(self, value: T) -> Result<(), PointerError>where
T: Sized,
Tries to write to the value pointed to by the pointer
§Errors
If the pointer is invalid due to unmapped memory or similar, returns PointerError
Sourcepub const unsafe fn cast_const(self) -> LocalUser<*const T>
pub const unsafe fn cast_const(self) -> LocalUser<*const T>
Casts to a readable pointer
§Safety
addr, if valid, must point to a valid bit pattern for T in the current address space.
This means that in almost all cases, it is unsound to cast to a LocalUser<*const T> where T
has a niche.
For all types with no invalid bit-patterns (i.e. all numeric types) it is sound to cast to
a LocalUser<*const T>.
pub fn is_aligned_to(self, align: usize) -> bool
pub fn addr(self) -> VirtualAddress
pub fn align_offset(self, align: usize) -> usizewhere
T: Sized,
Source§impl<T> LocalUser<*const [T]>
impl<T> LocalUser<*const [T]>
pub const fn len(self) -> usize
pub const fn is_empty(self) -> bool
pub const fn as_ptr(self) -> LocalUser<*const T>
pub fn read_to_box(self) -> Result<Box<[T]>, PointerError>
pub fn read_to_buffer( self, buffer: &mut [MaybeUninit<T>], ) -> Result<usize, PointerError>
Source§impl<T> LocalUser<*mut [T]>
impl<T> LocalUser<*mut [T]>
pub const fn len(self) -> usize
pub const fn is_empty(self) -> bool
pub const fn as_mut_ptr(self) -> LocalUser<*mut T>
pub fn write_from_slice(self, slice: &[T]) -> Result<usize, PointerError>
Trait Implementations§
impl<T: Copy> Copy for LocalUser<T>
impl<T> !Send for LocalUser<T>
impl<T> !Sync for LocalUser<T>
Auto Trait Implementations§
impl<T> Freeze for LocalUser<T>where
T: Freeze,
impl<T> RefUnwindSafe for LocalUser<T>where
T: RefUnwindSafe,
impl<T> Unpin for LocalUser<T>where
T: Unpin,
impl<T> UnsafeUnpin for LocalUser<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for LocalUser<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)