Struct ringbuf::Consumer[][src]

pub struct Consumer<T> { /* fields omitted */ }
Expand description

Consumer part of ring buffer.

Implementations

Returns capacity of the ring buffer.

The capacity of the buffer is constant.

Checks if the ring buffer is empty.

The result may become irrelevant at any time because of concurring activity of the producer.

Checks if the ring buffer is full.

The result is relevant until you remove items from the consumer.

The length of the data stored in the buffer

Actual length may be equal to or greater than the returned value.

The remaining space in the buffer.

Actual remaining space may be equal to or less than the returning value.

Gives immutable access to the elements contained by the ring buffer without removing them.

The method takes a function f as argument. f takes two slices of ring buffer content (the second one or both of them may be empty). First slice contains older elements.

The slices may not include elements pushed to the buffer by concurring producer after the method call.

Gives mutable access to the elements contained by the ring buffer without removing them.

The method takes a function f as argument. f takes two slices of ring buffer content (the second one or both of them may be empty). First slice contains older elements.

The iteration may not include elements pushed to the buffer by concurring producer after the method call.

Allows to read from ring buffer memory directry.

This function is unsafe because it gives access to possibly uninitialized memory

The method takes a function f as argument. f takes two slices of ring buffer content (the second one or both of them may be empty). First slice contains older elements.

f should return number of elements been read. There is no checks for returned number - it remains on the developer’s conscience.

The method always calls f even if ring buffer is empty.

The method returns number returned from f.

Safety

The method gives access to ring buffer underlying memory which may be uninitialized.

It’s up to you to copy or drop appropriate elements if you use this function.

Copies data from the ring buffer to the slice in byte-to-byte manner.

The elems slice should contain un-initialized data before the method call. After the call the copied part of data in elems should be interpreted as initialized. The remaining part is still un-iniitilized.

Returns the number of items been copied.

Safety

The method copies raw data from the ring buffer.

You should manage copied elements after call, otherwise you may get a memory leak.

Removes latest element from the ring buffer and returns it. Returns None if the ring buffer is empty.

Repeatedly calls the closure f passing elements removed from the ring buffer to it.

The closure is called until it returns false or the ring buffer is empty.

The method returns number of elements been removed from the buffer.

Iterate immutably over the elements contained by the ring buffer without removing them.

The iteration may not include elements pushed to the buffer by concurring producer after the method call.

Iterate mutably over the elements contained by the ring buffer without removing them.

The iteration may not include elements pushed to the buffer by concurring producer after the method call.

Removes n items from the buffer and safely drops them.

Returns the number of deleted items.

Removes at most count elements from the consumer and appends them to the producer. If count is None then as much as possible elements will be moved. The producer and consumer parts may be of different buffers as well as of the same one.

On success returns count of elements been moved.

Removes first elements from the ring buffer and writes them into a slice. Elements should be Copy.

On success returns count of elements been removed from the ring buffer.

Removes at most first count bytes from the ring buffer and writes them into a Write instance. If count is None then as much as possible bytes will be written.

Returns Ok(n) if write is succeded. n is number of bytes been written. n == 0 means that either write returned zero or ring buffer is empty.

If write is failed or returned an invalid number then error is returned.

Trait Implementations

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Like read, except that it reads into a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Reader has an efficient read_vectored implementation. Read more

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, appending them to buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a “by reference” adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Creates an adaptor which will chain this stream with another. Read more

Creates an adaptor which will read at most limit bytes from it. 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

Performs the conversion.

Performs the conversion.

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.