1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::engine;
include!(concat!(env!("OUT_DIR"), "/command_array.rs"));
pub struct Args<'a> {
count: u32,
index: u32,
engine: &'a engine::Engine,
}
impl<'a> Args<'a> {
#[inline]
pub fn new(engine: &'a engine::Engine) -> Self {
Self { count: engine.cmd_argc(),
index: 0,
engine: engine }
}
}
impl Iterator for Args<'_> {
type Item = String;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
if self.index == self.count {
None
} else {
let arg = self.engine.cmd_argv(self.index);
self.index += 1;
Some(arg)
}
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
((self.count - self.index) as usize, Some((self.count - self.index) as usize))
}
}
impl ExactSizeIterator for Args<'_> {}
pub trait Command: Send + Sync {
fn name(&self) -> &'static [u8];
fn callback(&self) -> unsafe extern "C" fn();
}