Skip to content
Merged
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
10 changes: 9 additions & 1 deletion src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::fs::OpenOptions;

use std::fmt;
use std::io;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::path::Path;

/// A reference to an open file on the filesystem.
Expand Down Expand Up @@ -120,6 +120,14 @@ impl File {
File { fd }
}

/// Converts a [`std::fs::File`][std] to a [`tokio_uring::fs::File`][file].
///
/// [std]: std::fs::File
/// [file]: File
pub fn from_std(file: std::fs::File) -> File {
File::from_shared_fd(SharedFd::new(file.into_raw_fd()))
}

/// Read some bytes at the specified offset from the file into the specified
/// buffer, returning how many bytes were read.
///
Expand Down