pub struct ChannelMap<T> { /* private fields */ }Expand description
Defines independently queued Channel instances under one name.
Supply an instance string for every publish, read, condition, and completion guard. Add the map
definition once to crate::PersistenceSchema.
Slash is prohibited in instance keys because it is a reserved character.
Implementations§
Source§impl<T> ChannelMap<T>
impl<T> ChannelMap<T>
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Defines a Channel map with a stable name.
Slash is prohibited because it is a reserved character.
Sourcepub fn load_messages(&self, instance: impl Into<String>) -> ChannelMapLoad
pub fn load_messages(&self, instance: impl Into<String>) -> ChannelMapLoad
Selects one slash-free map instance’s pending messages for a handler Context.
Sourcepub fn publish(
&self,
context: &mut Context,
instance: &str,
value: T,
) -> HandlerResult<()>where
T: Value,
pub fn publish(
&self,
context: &mut Context,
instance: &str,
value: T,
) -> HandlerResult<()>where
T: Value,
Stages one message for instance from the current invocation.
§Errors
Returns a crate::HandlerError when value cannot be encoded.
Sourcepub fn delete(
&self,
context: &mut Context,
instance: &str,
message_id: &str,
) -> HandlerResult<()>
pub fn delete( &self, context: &mut Context, instance: &str, message_id: &str, ) -> HandlerResult<()>
Stages best-effort deletion of one pending message from a Channel-map instance.
Sourcepub fn size(&self, context: &Context, instance: &str) -> HandlerResult<usize>
pub fn size(&self, context: &Context, instance: &str) -> HandlerResult<usize>
Returns the invocation snapshot’s message count for instance.
Sourcepub fn pending_messages(
&self,
context: &Context,
instance: &str,
) -> HandlerResult<Vec<ChannelMessage<T>>>where
T: Value,
pub fn pending_messages(
&self,
context: &Context,
instance: &str,
) -> HandlerResult<Vec<ChannelMessage<T>>>where
T: Value,
Returns one instance’s loaded pending messages in FIFO order.
§Errors
Returns a crate::HandlerError when the instance was not selected by the handler options
or when a Value cannot be decoded.
Sourcepub fn find_pending_message(
&self,
context: &Context,
instance: &str,
message_id: &str,
) -> HandlerResult<Option<ChannelMessage<T>>>where
T: Value,
pub fn find_pending_message(
&self,
context: &Context,
instance: &str,
message_id: &str,
) -> HandlerResult<Option<ChannelMessage<T>>>where
T: Value,
Finds one pending message by ID within one loaded map instance.
Returns Ok(None) when the loaded snapshot does not contain message_id.
§Errors
Returns the same errors as Self::pending_messages.
Sourcepub fn map_size(&self, context: &Context) -> HandlerResult<usize>
pub fn map_size(&self, context: &Context) -> HandlerResult<usize>
Returns the number of non-empty instances visible to the current handler.
Sourcepub fn all_instance_keys(&self, context: &Context) -> HandlerResult<Vec<String>>
pub fn all_instance_keys(&self, context: &Context) -> HandlerResult<Vec<String>>
Returns sorted decoded non-empty keys, including buffered publishes.
Sourcepub fn condition_results(
&self,
context: &Context,
instance: &str,
) -> HandlerResult<Vec<T>>where
T: Value,
pub fn condition_results(
&self,
context: &Context,
instance: &str,
) -> HandlerResult<Vec<T>>where
T: Value,
Decodes messages consumed by instance’s satisfied condition.
§Errors
Returns a crate::HandlerError when a message cannot be decoded.
Sourcepub fn for_one(&self, instance: &str) -> Condition
pub fn for_one(&self, instance: &str) -> Condition
Creates an instance condition that consumes exactly one message.
Sourcepub fn for_n(&self, instance: &str, count: usize) -> Condition
pub fn for_n(&self, instance: &str, count: usize) -> Condition
Creates an instance condition that consumes exactly count messages.
Sourcepub fn at_least(&self, instance: &str, count: usize) -> Condition
pub fn at_least(&self, instance: &str, count: usize) -> Condition
Creates an instance condition with an inclusive lower queue-size bound.
Sourcepub fn at_most(&self, instance: &str, count: usize) -> Condition
pub fn at_most(&self, instance: &str, count: usize) -> Condition
Creates a non-blocking instance condition consuming up to count queued messages.
When its surrounding Wait completes, it consumes messages queued then. An empty queue yields no messages.
Sourcepub fn range(
&self,
instance: &str,
at_least: Option<usize>,
at_most: Option<usize>,
) -> Condition
pub fn range( &self, instance: &str, at_least: Option<usize>, at_most: Option<usize>, ) -> Condition
Creates an instance condition that waits for the lower bound, then consumes to its upper.
Omitting the lower bound makes the condition complete immediately. Consumption uses only messages queued when the condition completes.
Sourcepub fn when_empty(&self, instance: &str) -> ChannelGuard
pub fn when_empty(&self, instance: &str) -> ChannelGuard
Creates a conditional-completion guard requiring instance to be empty.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ChannelMap<T>
impl<T> RefUnwindSafe for ChannelMap<T>
impl<T> Send for ChannelMap<T>
impl<T> Sync for ChannelMap<T>
impl<T> Unpin for ChannelMap<T>
impl<T> UnsafeUnpin for ChannelMap<T>
impl<T> UnwindSafe for ChannelMap<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request