Struct tarantool::space::UpdateOps

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

source

pub fn new() -> Self

source

pub fn with_capacity(capacity: usize) -> Self

source

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).

source

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).

source

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).

source

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).

source

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).

source

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).

source

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).

source

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).

source

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).

source

pub fn as_slice(&self) -> &[TupleBuffer]

source

pub fn into_inner(self) -> Vec<TupleBuffer>

source

pub fn encode(&self) -> Vec<u8>

source

pub fn encode_to(&self, w: &mut impl Write) -> Result<()>

Trait Implementations§

source§

impl AsRef<[TupleBuffer]> for UpdateOps

source§

fn as_ref(&self) -> &[TupleBuffer]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Default for UpdateOps

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<UpdateOps> for Vec<TupleBuffer>

source§

fn from(ops: UpdateOps) -> Vec<TupleBuffer>

Converts to this type from the input type.
source§

impl IntoIterator for UpdateOps

§

type Item = TupleBuffer

The type of the elements being iterated over.
§

type IntoIter = IntoIter<TupleBuffer>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.