Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ pub struct IO {
pub enum Operation<'io_op> {
Uninitialized,
Open {
pathname: Pin<&'io_op CStr>,
pathname: &'io_op CStr,
flags: OpenFlags,
},
Read {
fd: Fd,
buf: Pin<&'io_op mut [u8]>,
buf: &'io_op mut [u8],
offset: u64,
},
Write {
fd: Fd,
buf: Pin<&'io_op [u8]>,
buf: &'io_op [u8],
offset: u64,
},
Close {
Expand Down Expand Up @@ -356,7 +356,7 @@ impl IO {

pub async fn open<'io_op>(
&self,
pathname: Pin<&'io_op CStr>,
pathname: &'io_op CStr,
flags: OpenFlags,
) -> io::Result<Fd> {
let mut comp = Completion::<'io_op>::default();
Expand All @@ -374,7 +374,7 @@ impl IO {
pub async fn read<'io_op>(
&self,
fd: Fd,
buf: Pin<&'io_op mut [u8]>,
buf: &'io_op mut [u8],
offset: u64,
) -> io::Result<usize> {
let mut comp = Completion::<'io_op>::default();
Expand All @@ -392,7 +392,7 @@ impl IO {
pub async fn write<'io_op>(
&self,
fd: Fd,
buf: Pin<&'io_op [u8]>,
buf: &'io_op [u8],
offset: u64,
) -> io::Result<usize> {
let mut comp = Completion::<'io_op>::default();
Expand Down Expand Up @@ -640,7 +640,7 @@ mod tests {
let mut buf: [u8; 4096] = [0; 4096];

let amt = io
.read(fd, Pin::new(&mut buf[..]), 0)
.read(fd, &mut buf[..], 0)
.await
.expect("read should succeed");

Expand Down Expand Up @@ -676,15 +676,15 @@ mod tests {
buf[..expected.len()].copy_from_slice(expected.as_bytes());

let amt = io
.write(fd, Pin::new(&buf[..expected.len()]), 0)
.write(fd, &buf[..expected.len()], 0)
.await
.expect("write should succeed");

assert_eq!(amt, expected.len());

let mut read_buf = [0; 4096];
let amt = io
.read(fd, Pin::new(&mut read_buf[..]), 0)
.read(fd, &mut read_buf[..], 0)
.await
.expect("read should succeed");

Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async fn async_main(io: &IO) -> Result<()> {
.await?;
let stdout_fd = match io
.open(
pin!(c"/dev/stdout"),
c"/dev/stdout",
OpenFlags::WriteOnly | OpenFlags::Append,
)
.await
Expand Down Expand Up @@ -94,11 +94,11 @@ async fn run_server(io: &IO, socket_fd: Fd, stdout_fd: Fd) -> Result<()> {
.await?;
let mut buf = [0u8; 5000];
loop {
let amt = io.read(socket_fd, pin!(&mut buf[..4096]), 0).await?;
let amt = io.read(socket_fd, &mut buf[..4096], 0).await?;
buf[amt] = b'\n'; // Add a newline
let mut recv_buf = &buf[..amt + 1];
loop {
let amt = io.write(stdout_fd, pin!(recv_buf), 0).await?;
let amt = io.write(stdout_fd, recv_buf, 0).await?;
recv_buf = &recv_buf[amt..];
if recv_buf.is_empty() {
break;
Expand Down