feat(resource): add grant-checked fs resource operations
This commit is contained in:
1 parent
cd90f059b4
commit
fbe36bcc43
16 files changed
+812
-31
No files matched your search
@@ -478,6 +478,17 @@ pub(crate) fn dispatch(
|
||||
Err(error) => resource_recoverable(error),
|
||||
}
|
||||
}
|
||||
"resource.request" => {
|
||||
let operation = expect_text_value(take(&bound, "operation", builtin, span)?, span)?;
|
||||
let value_type = bound["arguments"].type_name();
|
||||
let Value::List(arguments) = take(&bound, "arguments", builtin, span)? else {
|
||||
return Err(RuntimeError::type_error(
|
||||
span,
|
||||
format!("resource.request arguments must be a List, got {value_type}"),
|
||||
));
|
||||
};
|
||||
interpreter.resource_request(&operation, arguments, &module, span)
|
||||
}
|
||||
other => Err(RuntimeError::new(
|
||||
ErrorCategory::KernelUnavailable,
|
||||
span,
|
||||
|
||||
@@ -903,6 +903,23 @@ impl<'a> Interpreter<'a> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Execute one non-streaming resource operation.
|
||||
pub(crate) fn resource_request(
|
||||
&mut self,
|
||||
operation: &str,
|
||||
args: Vec<Value>,
|
||||
module: &ModuleId,
|
||||
span: Option<Span>,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
let context = ExecutionContext::new(module.to_string(), span);
|
||||
self.host
|
||||
.resource_request(operation, args, &context)
|
||||
.map_err(|mut error| {
|
||||
error.mark_callsite();
|
||||
error
|
||||
})
|
||||
}
|
||||
|
||||
/// Close a resource stream.
|
||||
pub(crate) fn resource_close(
|
||||
&mut self,
|
||||
|
||||
Reference in new issue
Block a user