[][src]Struct samp::prelude::UnsizedBuffer

pub struct UnsizedBuffer<'amx> { /* fields omitted */ }

It's more like a temorary buffer that comes from AMX when a native is calling.

Example

use samp_sdk::cell::UnsizedBuffer;

fn null_my_array(amx: &Amx, array: UnsizedBuffer, length: usize) -> AmxResult<u32> {
    let mut array = array.into_sized_buffer(length);

    unsafe {
        let slice = array.as_mut_slice();
        std::ptr::write_bytes(slice.as_mut_ptr(), 0, length);
    }

    return Ok(1)
}

Methods

impl<'amx> UnsizedBuffer<'amx>[src]

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

Convert UnsizedBuffer into Buffer with given length.

Example

use samp_sdk::cell::UnsizedBuffer;

fn push_ones(amx: &Amx, array: UnsizedBuffer, length: usize) {
    let mut buffer = array.into_sized_buffer(length);
    let slice = buffer.as_mut_slice();
     
    for item in slice.iter_mut() {
        *item = 1;
    }
}

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

Return a raw pointer to an inner value.

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

Return a mutable raw pointer to an inner value.

Trait Implementations

impl<'amx> AmxCell<'amx> for UnsizedBuffer<'amx>[src]

Auto Trait Implementations

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

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

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.