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>
impl<'amx> UnsizedBuffer<'amx>
Sourcepub fn into_sized_buffer(self, len: usize) -> Buffer<'amx>
pub fn into_sized_buffer(self, len: usize) -> Buffer<'amx>
Converts into Buffer by declaring the size.
len should be the real Pawn array size (sizeof(arr)). A len larger
than the actual array still reads/writes neighbouring cells of the same
script (wrong data, not a crash), so never pass a size the script can
control independently. The SDK clamps len two ways as a safety net:
to the VM data region [0, stp) (so an oversized len cannot read or
write past the AMX allocation and segfault) and to a 1 MiB ceiling.
Sourcepub fn as_mut_ptr(&mut self) -> *mut i32
pub fn as_mut_ptr(&mut self) -> *mut i32
Mutable pointer to the first cell.
Sourcepub fn write_str(self, max_len: usize, s: &str) -> Result<(), AmxError>
pub fn write_str(self, max_len: usize, s: &str) -> Result<(), AmxError>
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).