mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
fs: impl AsRawFd / AsRawHandle for File (#1827)
This provides the ability to get the raw OS handle for a `File`. The `Into*` variant cannot be provided as `File` needs to maintain ownership of the `File`. The actual handle may have been moved to a background thread.
This commit is contained in:
parent
ebf5f37989
commit
c146f48f0b
@ -600,3 +600,17 @@ impl fmt::Debug for File {
|
|||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
impl std::os::unix::io::AsRawFd for File {
|
||||||
|
fn as_raw_fd(&self) -> std::os::unix::io::RawFd {
|
||||||
|
self.std.as_raw_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
impl std::os::windows::io::AsRawHandle for File {
|
||||||
|
fn as_raw_handle(&self) -> std::os::windows::io::RawHandle {
|
||||||
|
self.std.as_raw_handle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -263,3 +263,17 @@ impl fmt::Debug for File {
|
|||||||
fmt.debug_struct("mock::File").finish()
|
fmt.debug_struct("mock::File").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
impl std::os::unix::io::AsRawFd for File {
|
||||||
|
fn as_raw_fd(&self) -> std::os::unix::io::RawFd {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
impl std::os::windows::io::AsRawHandle for File {
|
||||||
|
fn as_raw_handle(&self) -> std::os::windows::io::RawHandle {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user