pub struct Sender { /* private fields */ }
Expand description

The sender part of the queue. This part is lock-free and therefore can be used outside an asynchronous context.

Implementations

Opens a queue on a folder indicated by the base path for sending. The folder will be created if it does not already exist.

Errors

This function will return an IO error if the queue is already in use for sending, which is indicated by a lock file. Also, any other IO error encountered while opening will be sent.

👎 Deprecated since 0.5.0:

the sender state is now always inferred. There is no need to save anything

Saves the sender queue state. You do not need to use method in most circumstances, since it is automatically done on drop (yes, it will be called eve if your thread panics). However, you can use this function to

  1. Make periodical backups. Use an external timer implementation for this.

  2. Handle possible IO errors in sending. The drop implementation will ignore (but log) any io errors, which may lead to data loss in an unreliable filesystem. It was implmemented this way because no errors are allowed to propagate on drop and panicking will abort the program if drop is called during a panic.

Tries to sends some data into the queue. If the queue is too big to insert (as set in max_queue_size), this returns TrySendError::QueueFull. One send is always atomic.

Errors

This function returns any underlying errors encountered while writing or flushing the queue. Also, it returns TrySendError::QueueFull if the queue is too big.

Sends some data into the queue. One send is always atomic. This function is async because the queue might be full and so we need to .await the receiver to consume enough segments to clear the queue.

Errors

This function returns any underlying errors encountered while writing or flushing the queue.

Tries to send all the contents of an iterable into the queue. If the queue is too big to insert (as set in max_queue_size), this returns TrySendError::QueueFull. All is buffered to be sent atomically, in one flush operation. Since this operation is atomic, it does not create new segments during the iteration. Be mindful of that when using this method for large writes.

Errors

This function returns any underlying errors encountered while writing or flushing the queue. Also, it returns TrySendError::QueueFull if the queue is too big.

Sends all the contents of an iterable into the queue. This function is async because the queue might be full and so we need to .await the receiver to consume enough segments to clear the queue. All is buffered to be sent atomically, in one flush operation. Since this operation is atomic, it does not create new segments during the iteration. Be mindful of that when using this method for large writes.

Errors

This function returns any underlying errors encountered while writing or flushing the queue.

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.