diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2024-10-15 15:36:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 15:36:11 -0700 |
commit | 82d13fd45b6fa8da5d390e26a349522e93811639 (patch) | |
tree | 2278d45f31961df69ea19678d5334f73d2bbc8e7 /ext/io/bi_pipe.rs | |
parent | ee904ec06c1a3b3d4e4a87898e777e2f9b587b07 (diff) |
refactor(ext/io): use concrete error types (#26187)
Diffstat (limited to 'ext/io/bi_pipe.rs')
-rw-r--r-- | ext/io/bi_pipe.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/ext/io/bi_pipe.rs b/ext/io/bi_pipe.rs index 402e383ac..b6fc70ca2 100644 --- a/ext/io/bi_pipe.rs +++ b/ext/io/bi_pipe.rs @@ -2,7 +2,6 @@ use std::rc::Rc; -use deno_core::error::AnyError; use deno_core::AsyncRefCell; use deno_core::AsyncResult; use deno_core::CancelHandle; @@ -71,13 +70,16 @@ impl BiPipeResource { pub async fn read( self: Rc<Self>, data: &mut [u8], - ) -> Result<usize, AnyError> { + ) -> Result<usize, std::io::Error> { let mut rd = RcRef::map(&self, |r| &r.read_half).borrow_mut().await; let cancel_handle = RcRef::map(&self, |r| &r.cancel); - Ok(rd.read(data).try_or_cancel(cancel_handle).await?) + rd.read(data).try_or_cancel(cancel_handle).await } - pub async fn write(self: Rc<Self>, data: &[u8]) -> Result<usize, AnyError> { + pub async fn write( + self: Rc<Self>, + data: &[u8], + ) -> Result<usize, std::io::Error> { let mut wr = RcRef::map(self, |r| &r.write_half).borrow_mut().await; let nwritten = wr.write(data).await?; wr.flush().await?; @@ -270,8 +272,8 @@ impl_async_write!(for BiPipe -> self.write_end); /// Creates both sides of a bidirectional pipe, returning the raw /// handles to the underlying OS resources. -pub fn bi_pipe_pair_raw() -> Result<(RawBiPipeHandle, RawBiPipeHandle), AnyError> -{ +pub fn bi_pipe_pair_raw( +) -> Result<(RawBiPipeHandle, RawBiPipeHandle), std::io::Error> { #[cfg(unix)] { // SockFlag is broken on macOS @@ -293,7 +295,7 @@ pub fn bi_pipe_pair_raw() -> Result<(RawBiPipeHandle, RawBiPipeHandle), AnyError ) }; if ret != 0 { - return Err(std::io::Error::last_os_error().into()); + return Err(std::io::Error::last_os_error()); } if cfg!(target_os = "macos") { @@ -389,7 +391,7 @@ pub fn bi_pipe_pair_raw() -> Result<(RawBiPipeHandle, RawBiPipeHandle), AnyError continue; } - return Err(err.into()); + return Err(err); } break (path, hd1); @@ -411,7 +413,7 @@ pub fn bi_pipe_pair_raw() -> Result<(RawBiPipeHandle, RawBiPipeHandle), AnyError 0, ); if hd2 == INVALID_HANDLE_VALUE { - return Err(io::Error::last_os_error().into()); + return Err(io::Error::last_os_error()); } // Will not block because we have create the pair. @@ -419,7 +421,7 @@ pub fn bi_pipe_pair_raw() -> Result<(RawBiPipeHandle, RawBiPipeHandle), AnyError let err = std::io::Error::last_os_error(); if err.raw_os_error() != Some(ERROR_PIPE_CONNECTED as i32) { CloseHandle(hd2); - return Err(err.into()); + return Err(err); } } |