#[repr(C)]
pub struct BytesReader { /* private fields */ }
Expand description

A BytesReader enables a reader to directly access bytes within a reserved section written by a BytesWriter. In some cases this can result in reduced read latency by eliminating a copy. It also enables Queue to be directly integrated with components which read directly from a region of memory.

Example

let tailer = queue.create_tailer().unwrap();
{
    let reader = tailer.scoped_bytes_reader();

    if !reader.is_empty() {
        let slice = reader.as_slice();
        ...
        // directly read from the slice (which reads directly from the Queue)
        ...
    }
}

Implementations§

Get a slice to the reserved section of the Queue as a &[u8]

Test if this BytesReader is invalid (returns true), or has available content (returns false)

As an equivalent check, the slice returned by as_slice will have 0 length if the BytesReader is empty

Set this BytesReader to rollback when closed (either explicitly by calling close(), or automatically when using a scoped reader). Rolling back leaves the reader in the same state and read position as before the read was attempted

Trait Implementations§

§

type Id

A type-level representation of the type’s C++ namespace and type name. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.