pub struct FdTable { /* private fields */ }Expand description
An FdTable is a table of file descriptors.
Implementations§
Source§impl FdTable
impl FdTable
Sourcepub fn fork(&self) -> FdTable
pub fn fork(&self) -> FdTable
Returns new unshared FdTable that is a snapshot of the state of the FdTable.
Ensures that this FdTable is not shared by any other FdTable instances.
Sourcepub fn release(&self)
pub fn release(&self)
Releases the FdTable, closing any files opened exclusively by this table.
Sourcepub fn insert<L>(
&self,
locked: &mut Locked<L>,
task: &Task,
fd: FdNumber,
file: FileHandle,
) -> Result<(), Errno>where
L: LockBefore<ThreadGroupLimits>,
pub fn insert<L>(
&self,
locked: &mut Locked<L>,
task: &Task,
fd: FdNumber,
file: FileHandle,
) -> Result<(), Errno>where
L: LockBefore<ThreadGroupLimits>,
Inserts a file descriptor into the table.
Sourcepub fn insert_with_flags<L>(
&self,
locked: &mut Locked<L>,
task: &Task,
fd: FdNumber,
file: FileHandle,
flags: FdFlags,
) -> Result<(), Errno>where
L: LockBefore<ThreadGroupLimits>,
pub fn insert_with_flags<L>(
&self,
locked: &mut Locked<L>,
task: &Task,
fd: FdNumber,
file: FileHandle,
flags: FdFlags,
) -> Result<(), Errno>where
L: LockBefore<ThreadGroupLimits>,
Inserts a file descriptor into the table with the specified flags.
Sourcepub fn add_with_flags<L>(
&self,
locked: &mut Locked<L>,
task: &Task,
file: FileHandle,
flags: FdFlags,
) -> Result<FdNumber, Errno>where
L: LockBefore<ThreadGroupLimits>,
pub fn add_with_flags<L>(
&self,
locked: &mut Locked<L>,
task: &Task,
file: FileHandle,
flags: FdFlags,
) -> Result<FdNumber, Errno>where
L: LockBefore<ThreadGroupLimits>,
Adds a file descriptor to the table.
The file descriptor will be assigned the next available number.
Returns the assigned file descriptor number.
This function is the most common way to add a file descriptor to the table.
Sourcepub fn duplicate<L>(
&self,
locked: &mut Locked<L>,
task: &Task,
oldfd: FdNumber,
target: TargetFdNumber,
flags: FdFlags,
) -> Result<FdNumber, Errno>where
L: LockBefore<ThreadGroupLimits>,
pub fn duplicate<L>(
&self,
locked: &mut Locked<L>,
task: &Task,
oldfd: FdNumber,
target: TargetFdNumber,
flags: FdFlags,
) -> Result<FdNumber, Errno>where
L: LockBefore<ThreadGroupLimits>,
Duplicates a file descriptor.
If target is TargetFdNumber::Minimum, a new FdNumber is allocated. Returns the new
FdNumber.
Sourcepub fn get_allowing_opath(&self, fd: FdNumber) -> Result<FileHandle, Errno>
pub fn get_allowing_opath(&self, fd: FdNumber) -> Result<FileHandle, Errno>
Returns the file handle associated with the given file descriptor.
Returns the file handle even if the file was opened with O_PATH.
This operation is uncommon. Most clients should use get instead, which fails if the file
was opened with O_PATH.
Sourcepub fn get_allowing_opath_with_flags(
&self,
fd: FdNumber,
) -> Result<(FileHandle, FdFlags), Errno>
pub fn get_allowing_opath_with_flags( &self, fd: FdNumber, ) -> Result<(FileHandle, FdFlags), Errno>
Returns the file handle and flags associated with the given file descriptor.
Returns the file handle even if the file was opened with O_PATH.
This operation is uncommon. Most clients should use get instead, which fails if the file
was opened with O_PATH.
Sourcepub fn get(&self, fd: FdNumber) -> Result<FileHandle, Errno>
pub fn get(&self, fd: FdNumber) -> Result<FileHandle, Errno>
Returns the file handle associated with the given file descriptor.
This operation fails if the file was opened with O_PATH.
Sourcepub fn close(&self, fd: FdNumber) -> Result<(), Errno>
pub fn close(&self, fd: FdNumber) -> Result<(), Errno>
Closes the file descriptor associated with the given file descriptor.
This operation fails if the file descriptor is not valid.
Sourcepub fn get_fd_flags_allowing_opath(
&self,
fd: FdNumber,
) -> Result<FdFlags, Errno>
pub fn get_fd_flags_allowing_opath( &self, fd: FdNumber, ) -> Result<FdFlags, Errno>
Returns the flags associated with the given file descriptor.
Returns the flags even if the file was opened with O_PATH.
Sourcepub fn set_fd_flags(&self, fd: FdNumber, flags: FdFlags) -> Result<(), Errno>
pub fn set_fd_flags(&self, fd: FdNumber, flags: FdFlags) -> Result<(), Errno>
Sets the flags associated with the given file descriptor.
This operation fails if the file descriptor was opened with O_PATH or is not valid.
Sourcepub fn set_fd_flags_allowing_opath(
&self,
fd: FdNumber,
flags: FdFlags,
) -> Result<(), Errno>
pub fn set_fd_flags_allowing_opath( &self, fd: FdNumber, flags: FdFlags, ) -> Result<(), Errno>
Sets the flags associated with the given file descriptor.
This operation fails if the file descriptor is not valid.
Sourcepub fn retain<F>(&self, predicate: F)
pub fn retain<F>(&self, predicate: F)
Retains only the FDs matching the given predicate.
The predicate is called with the FdNumber and a mutable reference to the FdFlags for
each entry in the FdTable. If the predicate returns false, the entry is removed from
the FdTable. Otherwise, the FdFlags are updated to the value modified by the predicate.
Sourcepub fn get_all_fds(&self) -> Vec<FdNumber>
pub fn get_all_fds(&self) -> Vec<FdNumber>
Returns a vector of all current file descriptors in the table.
Sourcepub fn remap<F: Fn(&FileHandle) -> Option<FileHandle>>(&self, predicate: F)
pub fn remap<F: Fn(&FileHandle) -> Option<FileHandle>>(&self, predicate: F)
Executes predicate(file) => maybe_replacement on every non-empty table entry.
Replaces file with replacement_file in the table when
maybe_replacement == Some(replacement_file).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FdTable
impl RefUnwindSafe for FdTable
impl Send for FdTable
impl Sync for FdTable
impl Unpin for FdTable
impl !UnwindSafe for FdTable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more