Trait rubble::link::queue::Producer[][src]

pub trait Producer {
    fn free_space(&self) -> u8;
fn produce_dyn(
        &mut self,
        payload_bytes: u8,
        f: &mut dyn FnMut(&mut ByteWriter<'_>) -> Result<Llid, Error>
    ) -> Result<(), Error>; fn produce_with<E>(
        &mut self,
        payload_bytes: u8,
        f: impl FnOnce(&mut ByteWriter<'_>) -> Result<Llid, E>
    ) -> Result<(), E>
    where
        E: From<Error>,
        Self: Sized
, { ... } }
Expand description

The producing (writing) half of a packet queue.

Required methods

Returns the largest payload size that can be successfully enqueued in the current state.

This is necessarily a conservative estimate, since the consumer half of the queue might remove a packet from the queue immediately after this function returns, creating more free space.

After a call to this method, the next call to any of the produce_* methods must not fail when a payload_bytes value less than or equal to the returned free payload space is passed.

Enqueues a PDU with known size using a closure.

This is an object-safe method complemented by its generic counterpart produce_with. Only this method need to be implemented.

This will check if payload_bytes are available in the queue, and bail with Error::Eof if not. If sufficient space is available, a ByteWriter with access to that space is constructed and f is called. If f returns a successful result, the data is committed to the queue. If not, the queue is left unchanged.

Provided methods

Enqueues a PDU with known size using a closure.

This will check if payload_bytes are available in the queue, and bail with Error::Eof if not. If sufficient space is available, a ByteWriter with access to that space is constructed and f is called. If f returns a successful result, the data is committed to the queue. If not, the queue is left unchanged.

Implementors