Struct ringbuf::Producer[][src]

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

Producer 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 is relevant until you push items to the producer.

Checks if the ring buffer is full.

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

The length of the data stored in the buffer.

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

The remaining space in the buffer.

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

Allows to write into 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 written. There is no checks for returned number - it remains on the developer’s conscience.

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

The method returns number returned from f.

Safety

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

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

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

Returns the number of items been copied.

Safety

The method copies raw data into the ring buffer.

You should properly fill the slice and manage remaining elements after copy.

Appends an element to the ring buffer. On failure returns an error containing the element that hasn’t beed appended.

Repeatedly calls the closure f and pushes elements returned from it to the ring buffer.

The closure is called until it returns None or the ring buffer is full.

The method returns number of elements been put into the buffer.

Appends elements from an iterator to the ring buffer. Elements that haven’t been added to the ring buffer remain in the iterator.

Returns count of elements been appended to the ring buffer.

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 number of elements been moved.

Appends elements from slice to the ring buffer. Elements should be Copy.

Returns count of elements been appended to the ring buffer.

Reads at most count bytes from Read instance and appends them to the ring buffer. If count is None then as much as possible bytes will be read.

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

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

Trait Implementations

Write a buffer into this writer, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

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

Determines if this Writer has an efficient write_vectored implementation. Read more

Attempts to write an entire buffer into this writer. Read more

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

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adaptor for this instance of Write. 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.