pub struct Streams { /* private fields */ }Expand description
Provides atomic stream update operations
Implementations§
Source§impl Streams
impl Streams
Sourcepub async fn update(
&self,
key: impl Into<String>,
ops: Vec<UpdateOp>,
) -> Result<UpdateResult, IIIError>
pub async fn update( &self, key: impl Into<String>, ops: Vec<UpdateOp>, ) -> Result<UpdateResult, IIIError>
Perform an atomic update on a stream key
All operations are applied atomically - either all succeed or none are applied.
§Arguments
key- The stream key to update (format: “stream_name::group_id::item_id”)ops- List of operations to apply atomically
§Returns
Returns UpdateResult containing the old and new values
§Example
ⓘ
let result = streams.update(
"orders::user-123::order-456",
vec![
UpdateOp::increment("total", 100),
UpdateOp::set("status", "processing".into()),
],
).await?;Sourcepub async fn increment(
&self,
key: impl Into<String>,
field: impl Into<String>,
by: i64,
) -> Result<UpdateResult, IIIError>
pub async fn increment( &self, key: impl Into<String>, field: impl Into<String>, by: i64, ) -> Result<UpdateResult, IIIError>
Sourcepub async fn decrement(
&self,
key: impl Into<String>,
field: impl Into<String>,
by: i64,
) -> Result<UpdateResult, IIIError>
pub async fn decrement( &self, key: impl Into<String>, field: impl Into<String>, by: i64, ) -> Result<UpdateResult, IIIError>
Atomically decrement a numeric field
Convenience method for a single decrement operation.
Sourcepub async fn set_field(
&self,
key: impl Into<String>,
field: impl Into<String>,
value: impl Into<Value>,
) -> Result<UpdateResult, IIIError>
pub async fn set_field( &self, key: impl Into<String>, field: impl Into<String>, value: impl Into<Value>, ) -> Result<UpdateResult, IIIError>
Sourcepub async fn remove_field(
&self,
key: impl Into<String>,
field: impl Into<String>,
) -> Result<UpdateResult, IIIError>
pub async fn remove_field( &self, key: impl Into<String>, field: impl Into<String>, ) -> Result<UpdateResult, IIIError>
Atomically remove a field
Convenience method for a single remove operation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Streams
impl RefUnwindSafe for Streams
impl Send for Streams
impl Sync for Streams
impl Unpin for Streams
impl UnwindSafe for Streams
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
Mutably borrows from an owned value. Read more