Replies: 2 comments
-
Could you specify what kind of streaming example you would like? |
Beta Was this translation helpful? Give feedback.
0 replies
-
refer to let mut cmd = Command::new("**");
cmd.stdout(Stdio::piped());
let mut process = match cmd.spawn() {
Ok(process) => process,
Err(e) => {
info!("Error running command: {}", e);
return Err(anyhow::anyhow!("Error running command"));
}
};
let mut stdout = process.stdout.take().unwrap();
let stream:AsyncStream<Result<bytes::Bytes, io::Error>, impl Future<Output=()>+Sized> = stream! {
let mut buffer = [0; 8192];
loop {
match stdout.read(&mut buffer) {
Ok(0) => break, // EOF
Ok(n) => yield Ok::<_, io::Error>(bytes::Bytes::copy_from_slice(&buffer[..n])),
Err(e) => {
eprintln!("Error reading stdout: {}", e);
break;
}
}
}
}; At this time, I want to use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, we are going to use your crate to build a distributed file system. Streaming is very important in this part, but I regret not seeing any relevant examples. I would be very happy if there were any. Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions