Skip to content

Commit 3d46e20

Browse files
committed
Impl From<RandomAccessFile> for SyncFile
1 parent 8031859 commit 3d46e20

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/file.rs

+13
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,19 @@ impl From<File> for SyncFile {
412412
}
413413
}
414414

415+
impl From<RandomAccessFile> for SyncFile {
416+
/// Creates a new `SyncFile` from an open [`RandomAccessFile`].
417+
///
418+
/// The cursor starts at the beginning of the file.
419+
#[inline]
420+
fn from(file: RandomAccessFile) -> SyncFile {
421+
SyncFile {
422+
file: Arc::new(file),
423+
offset: 0,
424+
}
425+
}
426+
}
427+
415428
#[cfg(any(unix, wasi_ext))]
416429
impl AsRawFd for SyncFile {
417430
#[inline]

0 commit comments

Comments
 (0)