pub struct Fd(/* private fields */);Available on crate feature
sys only.Expand description
File descriptor.
This type provides type-safe file descriptors. It uses the newtype pattern
with #[repr(transparent)] for zero-cost abstraction.
§Standard File Descriptors
0: Standard input (stdin)1: Standard output (stdout)2: Standard error (stderr)
§Platform Differences
- Linux/Unix: FDs are typically 32-bit signed integers
- Windows: Handles are used instead of FDs (this type is for Unix-like systems)
Implementations§
Source§impl Fd
impl Fd
Sourcepub const MAX: i32 = 1_048_576
Available on Linux only.
pub const MAX: i32 = 1_048_576
Maximum valid FD value (platform-dependent)
Sourcepub const fn new_unchecked(value: i32) -> Self
pub const fn new_unchecked(value: i32) -> Self
Creates a new FD without validation.
This constructor bypasses validation and should only be used when
the caller can guarantee the value is a valid file descriptor.
For validated construction, use Fd::new.
§Examples
use bare_types::sys::Fd;
// Standard file descriptors can be created directly
let stdin = Fd::new_unchecked(0);
assert!(stdin.is_stdin());Sourcepub const fn is_standard(&self) -> bool
pub const fn is_standard(&self) -> bool
Returns true if this is a standard file descriptor (stdin, stdout, or stderr).
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Fd
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Fd
Available on crate feature
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Generate an arbitrary value of
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for Fd
impl<'de> Deserialize<'de> for Fd
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Fd
impl Ord for Fd
Source§impl PartialOrd for Fd
impl PartialOrd for Fd
impl Copy for Fd
impl Eq for Fd
impl StructuralPartialEq for Fd
Auto Trait Implementations§
impl Freeze for Fd
impl RefUnwindSafe for Fd
impl Send for Fd
impl Sync for Fd
impl Unpin for Fd
impl UnwindSafe for Fd
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