siglus_scene_vm/runtime/commands/util.rs
1use crate::runtime::Value;
2
3/// Command arguments are now the original script arguments.
4/// The VM no longer appends synthetic element/al_id/ret_form metadata here.
5pub fn strip_vm_meta(args: &[Value]) -> &[Value] {
6 args
7}
8
9pub fn arg_as_i64(v: &Value) -> Option<i64> {
10 match v {
11 Value::Int(x) => Some(*x),
12 _ => None,
13 }
14}
15
16pub fn arg_as_usize(v: &Value) -> Option<usize> {
17 arg_as_i64(v).and_then(|x| usize::try_from(x).ok())
18}
19
20pub fn arg_as_str(v: &Value) -> Option<&str> {
21 match v {
22 Value::Str(s) => Some(s.as_str()),
23 _ => None,
24 }
25}