containerd / rust-extensions

Rust crates to extend containerd
https://containerd.io
Apache License 2.0
185 stars 76 forks source link

fix os_pipe doesn't work with async IO #326

Closed ningmingxiao closed 1 month ago

ningmingxiao commented 1 month ago

fix https://github.com/oconnor663/os_pipe.rs/issues/35

Mossaka commented 3 weeks ago

It looks like this PR broke the runc crate when async feature is not enabled.`

@ningmingxiao, @mxpv

Repro

$ cargo build -p runc               
   Compiling runc v0.2.0 (/home/mossaka/developer/spinkube/rust-extensions-fork/crates/runc)
error[E0433]: failed to resolve: use of undeclared crate or module `tokio`
  --> crates/runc/src/io.rs:34:5
   |
34 | use tokio::net::unix::pipe;
   |     ^^^^^ use of undeclared crate or module `tokio`

error[E0277]: the trait bound `OwnedFd: std::io::Write` is not satisfied
   --> crates/runc/src/io.rs:165:26
    |
165 |                 .map(|x| Box::new(x) as Box<dyn Write + Send + Sync>)
    |                          ^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `OwnedFd`
    |
    = note: required for the cast from `std::boxed::Box<OwnedFd>` to `std::boxed::Box<dyn std::io::Write + Send + Sync>`

error[E0277]: the trait bound `OwnedFd: std::io::Read` is not satisfied
   --> crates/runc/src/io.rs:185:26
    |
185 |                 .map(|x| Box::new(x) as Box<dyn Read + Send>)
    |                          ^^^^^^^^^^^ the trait `std::io::Read` is not implemented for `OwnedFd`
    |
    = note: required for the cast from `std::boxed::Box<OwnedFd>` to `std::boxed::Box<dyn std::io::Read + Send>`

error[E0277]: the trait bound `OwnedFd: std::io::Read` is not satisfied
   --> crates/runc/src/io.rs:205:26
    |
205 |                 .map(|x| Box::new(x) as Box<dyn Read + Send>)
    |                          ^^^^^^^^^^^ the trait `std::io::Read` is not implemented for `OwnedFd`
    |
    = note: required for the cast from `std::boxed::Box<OwnedFd>` to `std::boxed::Box<dyn std::io::Read + Send>`
mxpv commented 3 weeks ago

hmm, that's bad. Do you want to open a PR?