Refactor syscall modules to use async/await patterns
- Updated `DisplaySyscall` to use `tokio::io::AsyncWriteExt` for asynchronous text output. - Refactored `FsSyscall` to read files asynchronously with offset and length handling. - Modified `MemorySyscall` to use `tokio::task::spawn_blocking` for database operations, allowing async access to SQLite. - Enhanced `NetworkSyscall` to utilize `reqwest` for HTTP requests, replacing the previous `curl` command execution. - Improved `ProcessSyscall` to manage subprocesses with async tasks for stdin, stdout, and stderr handling. - Updated `TimerSyscall` to simplify timer management. - Adjusted plugin implementations for better async support and error handling. - Added `tokio-stream` and `tracing-subscriber` dependencies to `Cargo.toml` for enhanced async stream handling and logging.
This commit is contained in:
@@ -59,6 +59,7 @@ pub fn plugin_info(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn plugin_info_with_endpoint(
|
||||
id: &str,
|
||||
name: &str,
|
||||
@@ -95,7 +96,11 @@ pub fn encode_json<T: Serialize>(value: &T) -> Result<Vec<u8>> {
|
||||
serde_json::to_vec(value).context("encode JSON")
|
||||
}
|
||||
|
||||
pub fn call_response_json<T: Serialize>(value: &T, ok: bool, error: impl Into<String>) -> CallResponse {
|
||||
pub fn call_response_json<T: Serialize>(
|
||||
value: &T,
|
||||
ok: bool,
|
||||
error: impl Into<String>,
|
||||
) -> CallResponse {
|
||||
match encode_json(value) {
|
||||
Ok(result) => CallResponse {
|
||||
result,
|
||||
|
||||
Reference in New Issue
Block a user