(
state: &mut State<'gc>,
args: Vec<Value<'gc>>,
)
| 84 | } |
| 85 | |
| 86 | fn serde_from_file<'gc>( |
| 87 | state: &mut State<'gc>, |
| 88 | args: Vec<Value<'gc>>, |
| 89 | ) -> Result<Value<'gc>, VmError> { |
| 90 | if args.len() != 1 { |
| 91 | return Err(VmError::RuntimeError( |
| 92 | "from_file() takes exactly 1 argument".into(), |
| 93 | )); |
| 94 | } |
| 95 | |
| 96 | let path = string_arg!(&args, 0, "from_file")?; |
| 97 | |
| 98 | // Read file content |
| 99 | let content = fs::read_to_string(path.to_str().unwrap()) |
| 100 | .map_err(|e| VmError::RuntimeError(format!("Failed to read file: {}", e)))?; |
| 101 | |
| 102 | // Parse JSON content |
| 103 | let parsed = serde_json::from_str(&content) |
| 104 | .map_err(|e| VmError::RuntimeError(format!("Failed to parse JSON from file: {}", e)))?; |
| 105 | |
| 106 | // Convert to AIScript Value |
| 107 | Ok(Value::from_serde_value(state.get_context(), &parsed)) |
| 108 | } |
| 109 | |
| 110 | fn serde_to_file<'gc>( |
| 111 | _state: &mut State<'gc>, |
nothing calls this directly
no test coverage detected