Skip to main content

UnsizedBuffer

Struct UnsizedBuffer 

Source
pub struct UnsizedBuffer<'amx> { /* private fields */ }
Expand description

Array with unknown size — received as a native argument when the Pawn signature is array[] without a fixed dimension.

The actual size usually comes as another parameter (sizeof(array)). Use into_sized_buffer to convert into Buffer before iterating.

Implementations§

Source§

impl<'amx> UnsizedBuffer<'amx>

Source

pub fn into_sized_buffer(self, len: usize) -> Buffer<'amx>

Converts into Buffer by declaring the size.

len must be <= the actual number of allocated cells — larger values cause UB when accessing cells outside the Pawn array. The SDK caps it at 1 MiB as a defense against a corrupted len from the script.

Source

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

Pointer to the first cell.

Source

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

Mutable pointer to the first cell.

Source

pub fn write_str(self, max_len: usize, s: &str) -> AmxResult<()>

Sizes the buffer to max_len and writes s in one call.

Equivalent to into_sized_buffer(max_len).write_str(s). This is the recommended way to fill an output string in natives.

§Errors

AmxError::General if the encoded s is >= max_len (no room for the 0 terminator).

Trait Implementations§

Source§

impl<'amx> AmxCell<'amx> for UnsizedBuffer<'amx>

Source§

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

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

fn as_cell(&self) -> i32

Auto Trait Implementations§

§

impl<'amx> !Send for UnsizedBuffer<'amx>

§

impl<'amx> !Sync for UnsizedBuffer<'amx>

§

impl<'amx> Freeze for UnsizedBuffer<'amx>

§

impl<'amx> RefUnwindSafe for UnsizedBuffer<'amx>

§

impl<'amx> Unpin for UnsizedBuffer<'amx>

§

impl<'amx> UnsafeUnpin for UnsizedBuffer<'amx>

§

impl<'amx> UnwindSafe for UnsizedBuffer<'amx>

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<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.