#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.op: MutateInOpTypeThe type of mutation operation.
path: StringThe JSON path to mutate.
value: Vec<u8>The serialized value to write (empty for remove operations).
create_path: boolWhether to create intermediate path elements if they don’t exist.
is_xattr: boolWhether this operation targets an extended attribute (xattr).
expand_macros: boolWhether server-side macro expansion should be applied.
Implementations§
Source§impl MutateInSpec
impl MutateInSpec
Sourcepub fn insert<V: Serialize>(
path: impl Into<String>,
value: V,
opts: impl Into<Option<InsertSpecOptions>>,
) -> Result<Self>
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.
Sourcepub fn insert_raw(
path: impl Into<String>,
value: Vec<u8>,
opts: impl Into<Option<InsertSpecOptions>>,
) -> Self
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.
Sourcepub fn upsert<V: Serialize>(
path: impl Into<String>,
value: V,
opts: impl Into<Option<UpsertSpecOptions>>,
) -> Result<Self>
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.
Sourcepub fn upsert_raw(
path: impl Into<String>,
value: Vec<u8>,
opts: impl Into<Option<UpsertSpecOptions>>,
) -> Self
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.
Sourcepub fn replace<V: Serialize>(
path: impl Into<String>,
value: V,
opts: impl Into<Option<ReplaceSpecOptions>>,
) -> Result<Self>
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.
Sourcepub fn replace_raw(
path: impl Into<String>,
value: Vec<u8>,
opts: impl Into<Option<ReplaceSpecOptions>>,
) -> Self
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.
Sourcepub fn remove(
path: impl Into<String>,
opts: impl Into<Option<RemoveSpecOptions>>,
) -> Self
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.
Sourcepub fn array_append<V: Serialize>(
path: impl Into<String>,
value: &[V],
opts: impl Into<Option<ArrayAppendSpecOptions>>,
) -> Result<Self>
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.
Sourcepub fn array_append_raw(
path: impl Into<String>,
value: Vec<u8>,
opts: impl Into<Option<ArrayAppendSpecOptions>>,
) -> Self
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.
Sourcepub fn array_prepend<V: Serialize>(
path: impl Into<String>,
value: &[V],
opts: impl Into<Option<ArrayPrependSpecOptions>>,
) -> Result<Self>
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.
Sourcepub fn array_prepend_raw(
path: impl Into<String>,
value: Vec<u8>,
opts: impl Into<Option<ArrayPrependSpecOptions>>,
) -> Self
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.
Sourcepub fn array_insert<V: Serialize>(
path: impl Into<String>,
value: &[V],
opts: impl Into<Option<ArrayInsertSpecOptions>>,
) -> Result<Self>
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]".
Sourcepub fn array_insert_raw(
path: impl Into<String>,
value: Vec<u8>,
opts: impl Into<Option<ArrayInsertSpecOptions>>,
) -> Self
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.
Sourcepub fn array_add_unique<V: Serialize>(
path: impl Into<String>,
value: V,
opts: impl Into<Option<ArrayAddUniqueSpecOptions>>,
) -> Result<Self>
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).
Sourcepub fn array_add_unique_raw(
path: impl Into<String>,
value: Vec<u8>,
opts: impl Into<Option<ArrayAddUniqueSpecOptions>>,
) -> Self
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.
Trait Implementations§
Source§impl Clone for MutateInSpec
impl Clone for MutateInSpec
Source§fn clone(&self) -> MutateInSpec
fn clone(&self) -> MutateInSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MutateInSpec
impl Debug for MutateInSpec
Source§impl PartialEq for MutateInSpec
impl PartialEq for MutateInSpec
Source§impl SubdocOp for MutateInSpec
impl SubdocOp for MutateInSpec
fn is_xattr_op(&self) -> bool
Source§impl<'a> TryFrom<&'a MutateInSpec> for MutateInOp<'a>
impl<'a> TryFrom<&'a MutateInSpec> for MutateInOp<'a>
impl Eq for MutateInSpec
impl StructuralPartialEq for MutateInSpec
Auto Trait Implementations§
impl Freeze for MutateInSpec
impl RefUnwindSafe for MutateInSpec
impl Send for MutateInSpec
impl Sync for MutateInSpec
impl Unpin for MutateInSpec
impl UnsafeUnpin for MutateInSpec
impl UnwindSafe for MutateInSpec
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.