diff --git a/proxmox-sys/src/fs/read_dir.rs b/proxmox-sys/src/fs/read_dir.rs index 020f924d..430372da 100644 --- a/proxmox-sys/src/fs/read_dir.rs +++ b/proxmox-sys/src/fs/read_dir.rs @@ -22,9 +22,9 @@ pub struct ReadDirEntry { parent_fd: RawFd, } -impl Into for ReadDirEntry { - fn into(self) -> dir::Entry { - self.entry +impl From for dir::Entry { + fn from(this: ReadDirEntry) -> dir::Entry { + this.entry } } @@ -67,11 +67,18 @@ impl BorrowMut for ReadDirEntry { } 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()) } diff --git a/proxmox-sys/src/fs/xattr.rs b/proxmox-sys/src/fs/xattr.rs index 47637356..163a4119 100644 --- a/proxmox-sys/src/fs/xattr.rs +++ b/proxmox-sys/src/fs/xattr.rs @@ -135,9 +135,8 @@ pub fn fgetxattr(fd: RawFd, name: &CStr) -> Result, nix::errno::Errno> { /// 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()); diff --git a/proxmox-sys/src/linux/timer.rs b/proxmox-sys/src/linux/timer.rs index 40877a19..d18118ac 100644 --- a/proxmox-sys/src/linux/timer.rs +++ b/proxmox-sys/src/linux/timer.rs @@ -31,9 +31,9 @@ pub fn gettid() -> Tid { /// of...! pub struct Signal(c_int); -impl Into for Signal { - fn into(self) -> c_int { - self.0 +impl From for c_int { + fn from(this: Signal) -> c_int { + this.0 } }