[−][src]Struct samp::args::Args
A wrapper of a list of arguments of a native function.
Methods
impl<'a> Args<'a>[src]
pub fn new(amx: &'a Amx, args: *const i32) -> Args<'a>[src]
Creates a list from Amx and arguments.
Example
use samp_sdk::args::Args; use samp_sdk::amx::Amx; use samp_sdk::cell::AmxString; // native: RawNative(const say_that[]); extern "C" fn raw_native(amx: *mut AMX, args: *mut i32) -> i32 { // let amx_exports = ...; let amx = Amx::new(amx, amx_exports); let mut args = Args::new(&amx, args); let say_what = match args.next::<AmxString>() { Some(string) => string.to_string(), None => { println!("RawNative error: no argument"); return 0; } }; println!("RawNative: {}", say_what); return 1; }
pub fn next<T>(&mut self) -> Option<T> where
T: 'a + AmxCell<'a>, [src]
T: 'a + AmxCell<'a>,
Return the next argument in the list (like an iterator).
When there is no arguments left returns None.
pub fn get<T>(&self, offset: usize) -> Option<T> where
T: 'a + AmxCell<'a>, [src]
T: 'a + AmxCell<'a>,
Get an argument by position, if there is no argument in given location, returns None.
Example
use samp_sdk::args::Args; use samp_sdk::amx::Amx; use samp_sdk::cell::Ref; // native: NativeFn(player_id, &Float:health, &Float:armor); extern "C" fn raw_native(amx: *mut AMX, args: *mut i32) -> i32 { // let amx_exports = ...; let amx = Amx::new(amx, amx_exports); let args = Args::new(&amx, args); // change only armor args.get::<Ref<f32>>(2) .map(|mut armor| *armor = 255.0); return 1; }
pub fn reset(&mut self)[src]
Reset a read offset for next() method.
pub fn count(&self) -> usize[src]
Get count of arguments in the list.
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T> From for T[src]
impl<T, U> TryFrom for T where
T: From<U>, [src]
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId[src]
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,