pub struct PhantomMember<T, const OLD: isize, const NEW: isize> { /* private fields */ }
Expand description
A zero-sized marker used to access dynamically relocated members.
In the C++ class, it is not possible to simultaneously obtain mutable references
to multiple fields due to Rust’s borrowing rules. To work around this, PhantomMember
provides
an API for safely accessing individual fields while respecting the newer runtime offsets.
This struct is a placeholder that allows access to relocated members by providing runtime-based offset calculations.
§Generics
T
: Member typeOLD
: Offset when < ver.1_6_629NEW
: Offset when >= ver.1_6_629
Implementations§
Source§impl<T, const OLD: isize, const NEW: isize> PhantomMember<T, OLD, NEW>
impl<T, const OLD: isize, const NEW: isize> PhantomMember<T, OLD, NEW>
Sourcepub fn get(&self) -> Result<&T, RelocationError>
pub fn get(&self) -> Result<&T, RelocationError>
Retrieves a reference to the member as immutable.
§Safety
This performs an unsafe relocation based on runtime version checks.
Returns None
if the relocation fails.
§Errors
- This function may return an error if the module’s state cannot be accessed, or if the
map_active
call fails when fetching the current version. - If the pointer is null
- If the pointer is unaligned
Sourcepub fn get_mut(&mut self) -> Result<&mut T, RelocationError>
pub fn get_mut(&mut self) -> Result<&mut T, RelocationError>
Retrieves a mutable reference to the member.
§Safety
This performs an unsafe relocation based on runtime version checks.
Returns None
if the relocation fails.
§Errors
- This function may return an error if the module’s state cannot be accessed, or if the
map_active
call fails when fetching the current version. - If the pointer is null
- If the pointer is unaligned
Trait Implementations§
Source§impl<T, const OLD: isize, const NEW: isize> Debug for PhantomMember<T, OLD, NEW>where
T: Debug,
impl<T, const OLD: isize, const NEW: isize> Debug for PhantomMember<T, OLD, NEW>where
T: Debug,
Source§impl<T: Default, const OLD: isize, const NEW: isize> Default for PhantomMember<T, OLD, NEW>
impl<T: Default, const OLD: isize, const NEW: isize> Default for PhantomMember<T, OLD, NEW>
Source§fn default() -> PhantomMember<T, OLD, NEW>
fn default() -> PhantomMember<T, OLD, NEW>
Returns the “default value” for a type. Read more
Source§impl<T: Ord, const OLD: isize, const NEW: isize> Ord for PhantomMember<T, OLD, NEW>
impl<T: Ord, const OLD: isize, const NEW: isize> Ord for PhantomMember<T, OLD, NEW>
Source§fn cmp(&self, other: &PhantomMember<T, OLD, NEW>) -> Ordering
fn cmp(&self, other: &PhantomMember<T, OLD, NEW>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq, const OLD: isize, const NEW: isize> PartialEq for PhantomMember<T, OLD, NEW>
impl<T: PartialEq, const OLD: isize, const NEW: isize> PartialEq for PhantomMember<T, OLD, NEW>
Source§impl<T: PartialOrd, const OLD: isize, const NEW: isize> PartialOrd for PhantomMember<T, OLD, NEW>
impl<T: PartialOrd, const OLD: isize, const NEW: isize> PartialOrd for PhantomMember<T, OLD, NEW>
impl<T: Eq, const OLD: isize, const NEW: isize> Eq for PhantomMember<T, OLD, NEW>
impl<T, const OLD: isize, const NEW: isize> StructuralPartialEq for PhantomMember<T, OLD, NEW>
Auto Trait Implementations§
impl<T, const OLD: isize, const NEW: isize> Freeze for PhantomMember<T, OLD, NEW>
impl<T, const OLD: isize, const NEW: isize> RefUnwindSafe for PhantomMember<T, OLD, NEW>where
T: RefUnwindSafe,
impl<T, const OLD: isize, const NEW: isize> Send for PhantomMember<T, OLD, NEW>where
T: Send,
impl<T, const OLD: isize, const NEW: isize> Sync for PhantomMember<T, OLD, NEW>where
T: Sync,
impl<T, const OLD: isize, const NEW: isize> Unpin for PhantomMember<T, OLD, NEW>where
T: Unpin,
impl<T, const OLD: isize, const NEW: isize> UnwindSafe for PhantomMember<T, OLD, NEW>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more