Skip to main content

Ref

Struct Ref 

Source
pub struct Ref<'amx, T: Sized + AmxPrimitive> { /* private fields */ }
Expand description

Typed pointer to a live cell in the AMX heap/data.

Implements Deref and DerefMut for T, allowing reading and writing the cell directly (*r). The 'amx lifetime ensures the Ref does not outlive its Amx, avoiding dangling pointers.

Implementations§

Source§

impl<'amx, T: Sized + AmxPrimitive> Ref<'amx, T>

Source

pub unsafe fn new(amx_addr: i32, phys_addr: *mut T) -> Ref<'amx, T>

Creates a Ref from the (AMX address, physical address) pair, already resolved.

Prefer obtaining Ref via Amx::get_ref or via automatic parsing of native arguments — this direct API is the low-level path used internally by the SDK.

§Safety

phys_addr must point to a live T cell for as long as this Ref exists and must be aligned for T (debug asserts validate both conditions in builds with debug_assertions).

Source

pub fn address(&self) -> i32

Address of the cell in the AMX address space (not the physical pointer).

This is the value the VM sees — useful when passing the cell back into calls to other AMX functions.

Source

pub fn as_ptr(&self) -> *const T

Physical (host) pointer to the cell.

Source

pub fn as_mut_ptr(&mut self) -> *mut T

Mutable physical pointer to the cell.

Trait Implementations§

Source§

impl<'amx, T: Sized + AmxPrimitive> AmxCell<'amx> for Ref<'amx, T>

Source§

fn from_raw(amx: &'amx Amx, cell: i32) -> AmxResult<Ref<'amx, T>>

Reconstructs the value from a raw AMX cell. Read more
Source§

fn as_cell(&self) -> i32

Source§

impl<T: Sized + AmxPrimitive> Deref for Ref<'_, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: Sized + AmxPrimitive> DerefMut for Ref<'_, T>

Source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'amx, T> !Send for Ref<'amx, T>

§

impl<'amx, T> !Sync for Ref<'amx, T>

§

impl<'amx, T> Freeze for Ref<'amx, T>

§

impl<'amx, T> RefUnwindSafe for Ref<'amx, T>
where T: RefUnwindSafe,

§

impl<'amx, T> Unpin for Ref<'amx, T>

§

impl<'amx, T> UnsafeUnpin for Ref<'amx, T>

§

impl<'amx, T> UnwindSafe for Ref<'amx, T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.