pub struct Session { /* private fields */ }Expand description
A session between network device client and driver.
Implementations§
Source§impl Session
impl Session
Sourcepub async fn new(
device: &DeviceProxy,
name: &str,
config: Config,
) -> Result<(Self, Task)>
pub async fn new( device: &DeviceProxy, name: &str, config: Config, ) -> Result<(Self, Task)>
Creates a new session with the given name and config.
Sourcepub fn send(&self, buffer: Buffer<Tx>) -> Result<()>
pub fn send(&self, buffer: Buffer<Tx>) -> Result<()>
Sends a Buffer to the network device in this session.
Sourcepub async fn recv(&self) -> Result<Buffer<Rx>>
pub async fn recv(&self) -> Result<Buffer<Rx>>
Receives a Buffer from the network device in this session.
Sourcepub async fn alloc_tx_buffer(&self, num_bytes: usize) -> Result<Buffer<Tx>>
pub async fn alloc_tx_buffer(&self, num_bytes: usize) -> Result<Buffer<Tx>>
Allocates a Buffer that may later be queued to the network device.
The returned buffer will have at least num_bytes as size.
Sourcepub async fn alloc_tx_buffers(
&self,
num_bytes: usize,
) -> Result<impl Iterator<Item = Result<Buffer<Tx>>> + '_>
pub async fn alloc_tx_buffers( &self, num_bytes: usize, ) -> Result<impl Iterator<Item = Result<Buffer<Tx>>> + '_>
Waits for at least one TX buffer to be available and returns an iterator
of buffers with num_bytes as capacity.
The returned iterator is guaranteed to yield at least one item (though it might be an error if the requested size cannot meet the device requirement).
§Note
Given a Buffer<Tx> is returned to the pool when it’s dropped, the
returned iterator will seemingly yield infinite items if the yielded
Buffers are dropped while iterating.
Sourcepub async fn attach(&self, port: Port, rx_frames: &[FrameType]) -> Result<()>
pub async fn attach(&self, port: Port, rx_frames: &[FrameType]) -> Result<()>
Attaches Session to a port.
Sourcepub async fn wait_tx_idle(&self)
pub async fn wait_tx_idle(&self)
Blocks until there are no more tx buffers in flight to the backing device.
Note that this method does not prevent new buffers from being allocated and sent, it is up to the caller to prevent any races. This future will resolve as soon as it observes a tx idle event. That is, there are no frames in flight to the backing device at all and the session currently owns all allocated tx buffers.
The synchronization guarantee provided by this method is that any
buffers previously given to Session::send will be accounted as
pending until the device has replied back.
Sourcepub fn watch_rx_leases(
&self,
) -> impl Stream<Item = Result<RxLease>> + Send + Sync
pub fn watch_rx_leases( &self, ) -> impl Stream<Item = Result<RxLease>> + Send + Sync
Returns a stream of delegated rx leases from the device.
Leases are yielded from the stream whenever the corresponding receive buffer is dropped or reused for tx, which marks the end of processing the marked buffer for the delegated lease.
See fidl_fuchsia_hardware_network::DelegatedRxLease for more
details.
§Panics
Panics if the session was not created with
[fidl_fuchsia_hardware_network::SessionFlags::RECEIVE_RX_POWER_LEASES]
or if watch_rx_leases has already been called for this session.