diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-08-01 12:48:39 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-01 14:48:39 -0400 |
commit | 45572e329a395cb20ecb8c2867cc66b7d3a28cfe (patch) | |
tree | b54b46483048356848e4168ec052a583b7151191 /ext/io/fs.rs | |
parent | ab2627a014d3a5bb861e30e608cef0b6debb4ff2 (diff) |
refactor(runtime): use new fd methods from resource table (#20010)
Prereq for fast streams work. No longer need `#[cfg]` around
`backing_fd`.
Diffstat (limited to 'ext/io/fs.rs')
-rw-r--r-- | ext/io/fs.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/ext/io/fs.rs b/ext/io/fs.rs index 9afa192ab..1ebe0e7c1 100644 --- a/ext/io/fs.rs +++ b/ext/io/fs.rs @@ -12,6 +12,7 @@ use deno_core::error::AnyError; use deno_core::BufMutView; use deno_core::BufView; use deno_core::OpState; +use deno_core::ResourceHandleFd; use deno_core::ResourceId; use tokio::task::JoinError; @@ -236,10 +237,7 @@ pub trait File { // lower level functionality fn as_stdio(self: Rc<Self>) -> FsResult<std::process::Stdio>; - #[cfg(unix)] - fn backing_fd(self: Rc<Self>) -> Option<std::os::unix::prelude::RawFd>; - #[cfg(windows)] - fn backing_fd(self: Rc<Self>) -> Option<std::os::windows::io::RawHandle>; + fn backing_fd(self: Rc<Self>) -> Option<ResourceHandleFd>; fn try_clone_inner(self: Rc<Self>) -> FsResult<Rc<dyn File>>; } @@ -253,7 +251,7 @@ impl FileResource { Self { name, file } } - pub fn with_resource<F, R>( + fn with_resource<F, R>( state: &OpState, rid: ResourceId, f: F, @@ -359,13 +357,7 @@ impl deno_core::Resource for FileResource { self.file.clone().write_sync(data).map_err(|err| err.into()) } - #[cfg(unix)] - fn backing_fd(self: Rc<Self>) -> Option<std::os::unix::prelude::RawFd> { - self.file.clone().backing_fd() - } - - #[cfg(windows)] - fn backing_fd(self: Rc<Self>) -> Option<std::os::windows::io::RawHandle> { + fn backing_fd(self: Rc<Self>) -> Option<ResourceHandleFd> { self.file.clone().backing_fd() } } |