pub struct PacketBuilder<B> { /* private fields */ }
Expand description
Builds an aggregate usb packet out of vsock packets and gives readiness notifications when there is room to add another packet or data available to send.
Implementations§
Source§impl<B> PacketBuilder<B>
impl<B> PacketBuilder<B>
Source§impl<B> PacketBuilder<B>
impl<B> PacketBuilder<B>
Sourcepub fn available(&self) -> usize
pub fn available(&self) -> usize
Gets the space currently available for another packet in the buffer
Sourcepub fn wait_for_space(&self, bytes: usize) -> SpaceAvailableFuture<'_, B> ⓘ
pub fn wait_for_space(&self, bytes: usize) -> SpaceAvailableFuture<'_, B> ⓘ
Waits for there to be room to write a vsock packet of at least sizeof(Header)+bytes
in the buffer. Use Self::write_vsock_packet
to write the packet when
space becomes available.
§Panics
Panics if the buffer this was built with isn’t big enough to hold the packet even if it were empty.
Sourcepub fn wait_for_usb_packet(&self) -> UsbPacketFuture<'_, B> ⓘ
pub fn wait_for_usb_packet(&self) -> UsbPacketFuture<'_, B> ⓘ
Waits for a usb packet to be available in the buffer. Use Self::take_usb_packet
to get the packet when this returns.
Sourcepub fn write_vsock_packet(
&mut self,
packet: &Packet<'_>,
) -> Result<(), PacketTooBigError>
pub fn write_vsock_packet( &mut self, packet: &Packet<'_>, ) -> Result<(), PacketTooBigError>
Writes the given packet into the buffer. The packet and header must be able to fit within the buffer provided at creation time.
Sourcepub fn take_usb_packet(&mut self) -> Option<&mut [u8]>
pub fn take_usb_packet(&mut self) -> Option<&mut [u8]>
Takes the current usb packet, if there is one. The returned mutable slice will be only the data written to the buffer so far, and packet writing will be reset to the beginning of the buffer.