diff --git a/src/lib.rs b/src/lib.rs index daa0916cd284e1ca42996f9aba6ce3faf6bf7242..b2a97fdcfdc67c07fefa6d75e423d4ab37c79bb4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ extern crate alloc; use alloc::format; use core::str; +use core::task::Poll; use libredox::flag; use syscall::error::{Error, Result, EINTR}; @@ -215,6 +216,23 @@ impl Socket { pub struct Response(Cqe); impl Response { + #[inline] + pub fn err(err: i32, req: impl IntoTag) -> Self { + Self::new(Err(Error::new(err)), req) + } + #[inline] + pub fn ok(status: usize, req: impl IntoTag) -> Self { + Self::new(Ok(status), req) + } + #[inline] + pub fn ready_ok(status: usize, req: impl IntoTag) -> Poll<Self> { + Poll::Ready(Self::ok(status, req)) + } + #[inline] + pub fn ready_err(err: i32, req: impl IntoTag) -> Poll<Self> { + Poll::Ready(Self::err(err, req)) + } + pub fn new(status: Result<usize>, req: impl IntoTag) -> Self { Self(Cqe { flags: CqeOpcode::RespondRegular as u8,