Skip to main content

MutateInSpec

Struct MutateInSpec 

Source
#[non_exhaustive]
pub struct MutateInSpec { pub op: MutateInOpType, pub path: String, pub value: Vec<u8>, pub create_path: bool, pub is_xattr: bool, pub expand_macros: bool, }
Expand description

A sub-document mutation specification, used with Collection::mutate_in.

Create specs using the static constructors such as insert, upsert, replace, remove, array_append, array_prepend, array_insert, array_add_unique, increment, and decrement.

§Example

use couchbase::subdoc::mutate_in_specs::MutateInSpec;

let specs = vec![
    MutateInSpec::upsert("name", "Alice", None).unwrap(),
    MutateInSpec::remove("temp", None),
];

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§op: MutateInOpType

The type of mutation operation.

§path: String

The JSON path to mutate.

§value: Vec<u8>

The serialized value to write (empty for remove operations).

§create_path: bool

Whether to create intermediate path elements if they don’t exist.

§is_xattr: bool

Whether this operation targets an extended attribute (xattr).

§expand_macros: bool

Whether server-side macro expansion should be applied.

Implementations§

Source§

impl MutateInSpec

Source

pub fn insert<V: Serialize>( path: impl Into<String>, value: V, opts: impl Into<Option<InsertSpecOptions>>, ) -> Result<Self>

Creates an insert mutation spec that inserts a value at the given path.

Fails if the path already exists. The value is serialized to JSON via serde.

Source

pub fn insert_raw( path: impl Into<String>, value: Vec<u8>, opts: impl Into<Option<InsertSpecOptions>>, ) -> Self

Creates an insert mutation spec with pre-encoded raw bytes.

Source

pub fn upsert<V: Serialize>( path: impl Into<String>, value: V, opts: impl Into<Option<UpsertSpecOptions>>, ) -> Result<Self>

Creates an upsert mutation spec that sets the value at the given path, creating or overwriting it.

Source

pub fn upsert_raw( path: impl Into<String>, value: Vec<u8>, opts: impl Into<Option<UpsertSpecOptions>>, ) -> Self

Creates an upsert mutation spec with pre-encoded raw bytes.

Source

pub fn replace<V: Serialize>( path: impl Into<String>, value: V, opts: impl Into<Option<ReplaceSpecOptions>>, ) -> Result<Self>

Creates a replace mutation spec that replaces the value at the given path.

Fails if the path does not exist.

Source

pub fn replace_raw( path: impl Into<String>, value: Vec<u8>, opts: impl Into<Option<ReplaceSpecOptions>>, ) -> Self

Creates a replace mutation spec with pre-encoded raw bytes.

Source

pub fn remove( path: impl Into<String>, opts: impl Into<Option<RemoveSpecOptions>>, ) -> Self

Creates a remove mutation spec that removes the value at the given path.

Source

pub fn array_append<V: Serialize>( path: impl Into<String>, value: &[V], opts: impl Into<Option<ArrayAppendSpecOptions>>, ) -> Result<Self>

Appends one or more values to the end of an array at the given path.

Source

pub fn array_append_raw( path: impl Into<String>, value: Vec<u8>, opts: impl Into<Option<ArrayAppendSpecOptions>>, ) -> Self

Appends raw bytes to the end of an array at the given path.

Source

pub fn array_prepend<V: Serialize>( path: impl Into<String>, value: &[V], opts: impl Into<Option<ArrayPrependSpecOptions>>, ) -> Result<Self>

Prepends one or more values to the beginning of an array at the given path.

Source

pub fn array_prepend_raw( path: impl Into<String>, value: Vec<u8>, opts: impl Into<Option<ArrayPrependSpecOptions>>, ) -> Self

Prepends raw bytes to the beginning of an array at the given path.

Source

pub fn array_insert<V: Serialize>( path: impl Into<String>, value: &[V], opts: impl Into<Option<ArrayInsertSpecOptions>>, ) -> Result<Self>

Inserts one or more values at a specific position in an array.

The path must include the array index, e.g. "tags[2]".

Source

pub fn array_insert_raw( path: impl Into<String>, value: Vec<u8>, opts: impl Into<Option<ArrayInsertSpecOptions>>, ) -> Self

Inserts raw bytes at a specific position in an array.

Source

pub fn array_add_unique<V: Serialize>( path: impl Into<String>, value: V, opts: impl Into<Option<ArrayAddUniqueSpecOptions>>, ) -> Result<Self>

Adds a unique value to an array at the given path (no-op if it already exists).

Source

pub fn array_add_unique_raw( path: impl Into<String>, value: Vec<u8>, opts: impl Into<Option<ArrayAddUniqueSpecOptions>>, ) -> Self

Adds raw bytes as a unique value to an array at the given path.

Source

pub fn increment( path: impl Into<String>, delta: i64, opts: impl Into<Option<IncrementSpecOptions>>, ) -> Result<Self>

Increments a numeric value at the given path by the specified positive delta.

Returns an error if delta is negative.

Source

pub fn decrement( path: impl Into<String>, delta: i64, opts: impl Into<Option<DecrementSpecOptions>>, ) -> Result<Self>

Decrements a numeric value at the given path by the specified positive delta.

Returns an error if delta is negative.

Trait Implementations§

Source§

impl Clone for MutateInSpec

Source§

fn clone(&self) -> MutateInSpec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MutateInSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MutateInSpec

Source§

fn eq(&self, other: &MutateInSpec) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SubdocOp for MutateInSpec

Source§

impl<'a> TryFrom<&'a MutateInSpec> for MutateInOp<'a>

Source§

type Error = Error

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

fn try_from(value: &'a MutateInSpec) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for MutateInSpec

Source§

impl StructuralPartialEq for MutateInSpec

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more