pub trait FromFd {
// Required method
fn from_fd(owned: OwnedFd) -> Self;
// Provided method
fn from_into_fd<Owned: Into<OwnedFd>>(into_owned: Owned) -> Self
where Self: Sized + From<OwnedFd> { ... }
}
Expand description
A trait to express the ability to construct an object from a file descriptor.
Required Methods§
Sourcefn from_fd(owned: OwnedFd) -> Self
👎Deprecated since 1.0.0: FromFd::from_fd
is replaced by From<OwnedFd>::from
fn from_fd(owned: OwnedFd) -> Self
FromFd::from_fd
is replaced by From<OwnedFd>::from
Constructs a new instance of Self
from the given file descriptor.
§Example
use std::fs::File;
use io_lifetimes::{FromFd, IntoFd, OwnedFd};
let f = File::open("foo.txt")?;
let owned_fd: OwnedFd = f.into_fd();
let f = File::from_fd(owned_fd);
Provided Methods§
Sourcefn from_into_fd<Owned: Into<OwnedFd>>(into_owned: Owned) -> Self
fn from_into_fd<Owned: Into<OwnedFd>>(into_owned: Owned) -> Self
Constructs a new instance of Self
from the given file descriptor
converted from into_owned
.
§Example
use std::fs::File;
use io_lifetimes::{FromFd, IntoFd};
let f = File::open("foo.txt")?;
let f = File::from_into_fd(f);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.