Skip to content

Commit 68cefe7

Browse files
authored
fs_utf8: Add as_cap_std() (#357)
I'm looking at adding support in https://github.com/coreos/cap-std-ext/ for `fs_utf8`, and doing so really wants access to the currently internal `cap_std` member in order to share code - in the same way basically all the implementation functions here just delgate to the underlying `Dir`. I changed one usage to call this helper. Signed-off-by: Colin Walters <[email protected]>
1 parent 1dc17d3 commit 68cefe7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cap-std/src/fs_utf8/dir.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,22 @@ impl Dir {
5454
Self { cap_std }
5555
}
5656

57+
/// Return a view of this directory as a [`cap_std::fs::Dir`]. This
58+
/// is often useful in order to write shared functions which can operate
59+
/// on either type.
60+
#[inline]
61+
pub fn as_cap_std(&self) -> &crate::fs::Dir {
62+
&self.cap_std
63+
}
64+
5765
/// Attempts to open a file in read-only mode.
5866
///
5967
/// This corresponds to [`std::fs::File::open`], but only accesses paths
6068
/// relative to `self`.
6169
#[inline]
6270
pub fn open<P: AsRef<Utf8Path>>(&self, path: P) -> io::Result<File> {
6371
let path = from_utf8(path.as_ref())?;
64-
self.cap_std.open(path).map(File::from_cap_std)
72+
self.as_cap_std().open(path).map(File::from_cap_std)
6573
}
6674

6775
/// Opens a file at `path` with the options specified by `options`.

0 commit comments

Comments
 (0)