Skip to main content

Queue

Struct Queue 

Source
pub struct Queue<S, V, C = SystemClock> { /* private fields */ }
Expand description

A brokerless queue occupying exactly one object.

The object store is retained through an Arc, matching the sharing model used by other objsds structure handles.

Implementations§

Source§

impl<S, V, C> Queue<S, V, C>

Source

pub fn publish(&self, value: V) -> Result<MessageId, Error<S::Error>>

Publishes a message and returns its stable identifier.

A conflict means the message was not applied. A store error can be ambiguous; retrying with a new generated ID can therefore duplicate a message.

Source

pub fn claim( &self, lease_duration: Duration, ) -> Result<Option<Claim<V>>, Error<S::Error>>
where V: Clone,

Claims the oldest available message for the requested lease duration.

A message is available when never claimed or when its prior lease’s exclusive deadline is at or before the current clock value. Returns None without writing if no message is available.

Source

pub fn ack( &self, id: MessageId, token: LeaseToken, ) -> Result<Ack, Error<S::Error>>

Acknowledges and removes a message when the current unexpired lease matches.

Ack::Acknowledged is the only durable outcome. Other Ack values return without writing, so callers must not treat them as a stable terminal state without reading a fresh snapshot or claiming again.

Source

pub fn len(&self) -> Result<usize, Error<S::Error>>

Returns the number of unacknowledged messages in one snapshot.

Source

pub fn is_empty(&self) -> Result<bool, Error<S::Error>>

Returns whether the queue has no unacknowledged messages.

Auto Trait Implementations§

§

impl<S, V, C> Freeze for Queue<S, V, C>
where Arc<S>: Freeze, C: Freeze, PhantomData<fn() -> V>: Freeze,

§

impl<S, V, C> RefUnwindSafe for Queue<S, V, C>

§

impl<S, V, C> Send for Queue<S, V, C>
where Arc<S>: Send, C: Send, PhantomData<fn() -> V>: Send,

§

impl<S, V, C> Sync for Queue<S, V, C>
where Arc<S>: Sync, C: Sync, PhantomData<fn() -> V>: Sync,

§

impl<S, V, C> Unpin for Queue<S, V, C>
where Arc<S>: Unpin, C: Unpin, PhantomData<fn() -> V>: Unpin,

§

impl<S, V, C> UnsafeUnpin for Queue<S, V, C>

§

impl<S, V, C> UnwindSafe for Queue<S, V, C>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.