rust-samp-sdk 3.6.0

Low-level FFI bindings for the SA-MP AMX virtual machine and open.mp native component ABI. Used internally by `rust-samp`; depend on it directly only if you need raw access without the higher-level macros and lifecycle.
Documentation
//! `ITimer` — generated by `cargo xtask gen-omp` from `Server/Components/Timers/timers.hpp`.
//! Implemented by `Timer` in the server's `Timers`.
//!
//! Do not edit: change `xtask/omp-wrappers.toml` or the generator and
//! regenerate. Slots are clang's layout of the header for each ABI, checked
//! against the official binaries by `cargo xtask check-abi --generated`.

#![allow(unused_imports)]

use crate::omp::containers::{FlatSet, HybridString, Pair, Span};
use crate::omp::types::{
    Colour, GTAQuat, Hours, Microseconds, Milliseconds, Minutes, Seconds, StringView, TimePoint,
    UID, Vector2, Vector3, Vector4, WorldTimePoint,
};
use crate::omp::vtable::{call_vtable_small_struct, opaque, slots, virtual_fns};
use crate::omp::*;

slots! {
    /// `bool ITimer::running()`
    SLOT_RUNNING: usize = 6, 5;
    /// `Milliseconds ITimer::remaining()`
    SLOT_REMAINING: usize = 7, 6;
    /// `unsigned int ITimer::calls()`
    SLOT_CALLS: usize = 8, 7;
    /// `Milliseconds ITimer::interval()`
    SLOT_INTERVAL: usize = 9, 8;
    /// `bool ITimer::trigger()`
    SLOT_TRIGGER: usize = 10, 9;
    /// `TimerTimeOutHandler * ITimer::handler()`
    SLOT_HANDLER: usize = 12, 11;
}

virtual_fns! {
    /// `bool ITimer::running()`.
    ///
    /// # Safety
    /// `timer` must be a live `ITimer`.
    #[must_use]
    pub fn timer_running(timer: ITimer) -> bool = [0, SLOT_RUNNING] or false;

    /// `unsigned int ITimer::calls()`.
    ///
    /// # Safety
    /// `timer` must be a live `ITimer`.
    #[must_use]
    pub fn timer_calls(timer: ITimer) -> u32 = [0, SLOT_CALLS] or 0;

    /// `bool ITimer::trigger()`.
    ///
    /// # Safety
    /// `timer` must be a live `ITimer`.
    #[must_use]
    pub fn timer_trigger(timer: ITimer) -> bool = [0, SLOT_TRIGGER] or false;

    /// `TimerTimeOutHandler * ITimer::handler()`.
    ///
    /// # Safety
    /// `timer` must be a live `ITimer`.
    #[must_use]
    pub fn timer_handler(
        timer: ITimer,
    ) -> *mut TimerTimeOutHandler = [0, SLOT_HANDLER] or std::ptr::null_mut();
}

/// `Milliseconds ITimer::remaining()`.
///
/// # Safety
/// `timer` must be a live `ITimer`.
#[must_use]
pub unsafe fn timer_remaining(timer: *mut ITimer) -> Option<Milliseconds> {
    call_vtable_small_struct!(
        timer.cast::<u8>(),
        0,
        SLOT_REMAINING,
        Milliseconds,
        Milliseconds::default()
    )
}

/// `Milliseconds ITimer::interval()`.
///
/// # Safety
/// `timer` must be a live `ITimer`.
#[must_use]
pub unsafe fn timer_interval(timer: *mut ITimer) -> Option<Milliseconds> {
    call_vtable_small_struct!(
        timer.cast::<u8>(),
        0,
        SLOT_INTERVAL,
        Milliseconds,
        Milliseconds::default()
    )
}

// What the generator left out, and why.
// skipped: `void ITimer::kill()` — covered by a hand-written wrapper under another name