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:
2026-06-10 01:26:46 +08:00
parent f7919eca40
commit d533d0a30e
21 changed files with 1950 additions and 436 deletions

View File

@@ -26,7 +26,10 @@ async fn main() -> Result<()> {
.await?
.into_inner();
ensure!(register.ok, "register failed: {}", register.error);
println!("Register: ok={} session={}", register.ok, register.session_id);
println!(
"Register: ok={} session={}",
register.ok, register.session_id
);
let mut display = DisplayClient::new(channel.clone());
let resp = display
@@ -84,7 +87,11 @@ async fn main() -> Result<()> {
ensure!(resp.ok, "FS.List failed: {}", resp.error);
println!("FS.List: ok={} entries={}", resp.ok, resp.entries.len());
for entry in resp.entries.iter().take(5) {
println!(" {} {}", entry.name, if entry.is_dir { "[dir]" } else { "" });
println!(
" {} {}",
entry.name,
if entry.is_dir { "[dir]" } else { "" }
);
}
println!("\nAll syscalls verified OK!");