async_flow/io/port.rs
1// This is free and unencumbered software released into the public domain.
2
3use core::fmt::Debug;
4use dogma::{MaybeLabeled, MaybeNamed};
5
6/// The common interface for ports, whether for input or output.
7pub trait Port<T>: Debug + MaybeNamed + MaybeLabeled {
8 /// Checks if a port is closed.
9 fn is_closed(&self) -> bool;
10
11 /// Closes the port without dropping it.
12 fn close(&mut self);
13
14 /// Returns the remaining buffer capacity of the connection.
15 fn capacity(&self) -> Option<usize> {
16 None // unknown
17 }
18
19 /// Returns the maximum buffer capacity of the connection.
20 fn max_capacity(&self) -> Option<usize> {
21 None // unknown
22 }
23}