close() fds that have nothing more to read
This commit is contained in:
parent
b11627d030
commit
16f2649334
3 changed files with 108 additions and 67 deletions
|
|
@ -67,6 +67,10 @@ impl FdInfo {
|
|||
|
||||
self.name.get().unwrap_or_else(|| unreachable!())
|
||||
}
|
||||
|
||||
pub fn display(&self) -> FdInfoDisplay<'_> {
|
||||
FdInfoDisplay { inner: self }
|
||||
}
|
||||
}
|
||||
|
||||
impl IdOrdItem for FdInfo {
|
||||
|
|
@ -79,6 +83,27 @@ impl IdOrdItem for FdInfo {
|
|||
iddqd::id_upcast!();
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FdInfoDisplay<'a> {
|
||||
inner: &'a FdInfo,
|
||||
}
|
||||
impl<'a> Display for FdInfoDisplay<'a> {
|
||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||
write!(
|
||||
f,
|
||||
"{} fd {} ({})",
|
||||
self.inner.kind.name_str(),
|
||||
self.inner.fd,
|
||||
self.inner.name().to_string_lossy(),
|
||||
)?;
|
||||
if !self.inner.error_buffer.is_empty() {
|
||||
write!(f, "; with errors: {}", self.inner.error_buffer.len())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[non_exhaustive]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue