parent_fd: RawFd,
}
-impl Into<dir::Entry> for ReadDirEntry {
- fn into(self) -> dir::Entry {
- self.entry
+impl From<ReadDirEntry> for dir::Entry {
+ fn from(this: ReadDirEntry) -> dir::Entry {
+ this.entry
}
}
}
impl ReadDirEntry {
+ /// Get the parent directory's file descriptor.
#[inline]
pub fn parent_fd(&self) -> RawFd {
self.parent_fd
}
+ /// Get the file name as a `&str`.
+ ///
+ /// # Safety
+ ///
+ /// It is up to the user to ensure that the file name is valid utf-8 *before* calling this
+ /// method.
pub unsafe fn file_name_utf8_unchecked(&self) -> &str {
std::str::from_utf8_unchecked(self.file_name().to_bytes())
}
/// Set an extended attribute on a file descriptor.
pub fn fsetxattr(fd: RawFd, name: &CStr, data: &[u8]) -> Result<(), nix::errno::Errno> {
- let flags = 0 as libc::c_int;
let result = unsafe {
- libc::fsetxattr(fd, name.as_ptr(), data.as_ptr() as *const libc::c_void, data.len(), flags)
+ libc::fsetxattr(fd, name.as_ptr(), data.as_ptr() as *const libc::c_void, data.len(), 0)
};
if result < 0 {
return Err(Errno::last());
/// of...!
pub struct Signal(c_int);
-impl Into<c_int> for Signal {
- fn into(self) -> c_int {
- self.0
+impl From<Signal> for c_int {
+ fn from(this: Signal) -> c_int {
+ this.0
}
}