Struct yaque::queue::Sender

source ·
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§

source§

impl Sender

source

pub fn open<P: AsRef<Path>>(base: P) -> Result<Sender>

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.

source

pub fn save(&mut self) -> Result<()>

👎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 implemented this way because no errors are allowed to propagate on drop and panicking will abort the program if drop is called during a panic.

source

pub fn try_send<D: AsRef<[u8]>>( &mut self, data: D ) -> Result<(), TrySendError<D>>

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.

source

pub async fn send<D: AsRef<[u8]>>(&mut self, data: D) -> Result<()>

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.

source

pub fn try_send_batch<I>(&mut self, it: I) -> Result<(), TrySendError<I>>where I: IntoIterator, I::Item: AsRef<[u8]>,

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.

source

pub async fn send_batch<I>(&mut self, it: I) -> Result<()>where I: IntoIterator, I::Item: AsRef<[u8]>,

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§

§

impl !RefUnwindSafe for Sender

§

impl Send for Sender

§

impl Sync for Sender

§

impl Unpin for Sender

§

impl !UnwindSafe for Sender

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V