pub struct UpdateOps { /* private fields */ }
Expand description
A builder-style helper struct for Space::update
, Space::upsert
,
Index::update
, Index::upsert
methods.
Start by calling the new
function, then chain as many operations as
needed (add
, assign
, insert
, etc.) after that you can either
pass the resulting expression directly into one of the supported methods,
or use the data directly after calling encode
or into_inner
.
Examples
use tarantool::space::{Space, UpdateOps};
let mut space = Space::find("employee").unwrap();
space.update(
&[1337],
UpdateOps::new()
.add("strikes", 1).unwrap()
.assign("days-since-last-mistake", 0).unwrap(),
)
.unwrap();
Implementations§
source§impl UpdateOps
impl UpdateOps
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
sourcepub fn assign<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
pub fn assign<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
Assignment operation.
Corresponds to tarantool’s {'=', field, value}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).
sourcepub fn insert<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
pub fn insert<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
Insertion operation.
Corresponds to tarantool’s {'!', field, value}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).
sourcepub fn add<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
pub fn add<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
Numeric addition operation.
Corresponds to tarantool’s {'+', field, value}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).
sourcepub fn sub<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
pub fn sub<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
Numeric subtraction operation.
Corresponds to tarantool’s {'-', field, value}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).
sourcepub fn and<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
pub fn and<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
Bitwise AND operation.
Corresponds to tarantool’s {'&', field, value}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).
sourcepub fn or<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
pub fn or<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
Bitwise OR operation.
Corresponds to tarantool’s {'|', field, value}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).
sourcepub fn xor<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
pub fn xor<K, V>(&mut self, field: K, value: V) -> Result<&mut Self>where
K: Serialize,
V: Serialize,
Bitwise XOR operation.
Corresponds to tarantool’s {'^', field, value}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).
sourcepub fn delete<K>(&mut self, field: K, count: usize) -> Result<&mut Self>where
K: Serialize,
pub fn delete<K>(&mut self, field: K, count: usize) -> Result<&mut Self>where
K: Serialize,
Deletion operation.
Corresponds to tarantool’s {'#', field, count}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).
sourcepub fn splice<K>(
&mut self,
field: K,
start: isize,
count: usize,
value: &str
) -> Result<&mut Self>where
K: Serialize,
pub fn splice<K>(
&mut self,
field: K,
start: isize,
count: usize,
value: &str
) -> Result<&mut Self>where
K: Serialize,
String splicing operation.
Corresponds to tarantool’s {':', field, start, count, value}
.
Field indexing is zero based (first field has index 0). Negative indexes are offset from array’s end (last field has index -1).