pub struct DuplicatingFD(/* private fields */);Expand description
Implements Clone trait that calls dup(2) on
underlying handle and returns new instance wrapping dup-ped handle.
Warning: clone() will panic if dup(2) returns error.
Each clone()/dup() of DuplicatingFD contains a different handle.
§Example
use pakr_managedrawfd::*;
use std::os::unix::io::AsRawFd;
let stdout_handle = std::io::stdout().lock().as_raw_fd();
// We don't want myH to close the real stdout, therefore dup_wrap;
let myDupH = DuplicatingFD::dup_wrap(stdout_handle).unwrap();
// ... myDupH shall have handle other than stdout.
assert_ne!(myDupH.as_raw_fd(),stdout_handle);
// Clone it
let myOtherDupH = myDupH.clone();
// ... myOtherDupH shall have yet another handle, other than both myDupH and stdout.
assert_ne!(myOtherDupH.as_raw_fd(),stdout_handle);
assert_ne!(myOtherDupH.as_raw_fd(),myDupH.as_raw_fd());
Trait Implementations§
Source§impl AsRawFd for DuplicatingFD
impl AsRawFd for DuplicatingFD
Source§impl Clone for DuplicatingFD
impl Clone for DuplicatingFD
Source§impl ManagedFD for DuplicatingFD
impl ManagedFD for DuplicatingFD
Auto Trait Implementations§
impl Freeze for DuplicatingFD
impl RefUnwindSafe for DuplicatingFD
impl Send for DuplicatingFD
impl Sync for DuplicatingFD
impl Unpin for DuplicatingFD
impl UnwindSafe for DuplicatingFD
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more