pub struct Operation {
    pub collection: CollectionName,
    pub command: Command,
}
Expand description

A single operation performed on a Collection.

Fields§

§collection: CollectionName

The id of the Collection.

§command: Command

The command being performed.

Implementations§

source§

impl Operation

source

pub fn insert( collection: CollectionName, id: Option<DocumentId>, contents: impl Into<Bytes> ) -> Self

Inserts a new document with contents into collection. If id is None a unique id will be generated. If an id is provided and a document already exists with that id, a conflict error will be returned.

source

pub fn insert_serialized<C: SerializedCollection>( id: Option<&C::PrimaryKey>, contents: &C::Contents ) -> Result<Self, Error>

Inserts a new document with the serialized representation of contents into collection. If id is None a unique id will be generated. If an id is provided and a document already exists with that id, a conflict error will be returned.

source

pub fn push_serialized<C: SerializedCollection>( contents: &C::Contents ) -> Result<Self, Error>

Pushes a new document with the serialized representation of contents into collection.

Automatic ID Assignment

This function calls SerializedCollection::natural_id() to try to retrieve a primary key value from contents. If an id is returned, the item is inserted with that id. If an id is not returned, an id will be automatically assigned, if possible, by the storage backend, which uses the Key trait to assign ids.

source

pub fn update( collection: CollectionName, header: Header, contents: impl Into<Bytes> ) -> Self

Updates a document in collection.

source

pub fn update_serialized<C: SerializedCollection>( header: CollectionHeader<C::PrimaryKey>, contents: &C::Contents ) -> Result<Self, Error>

Updates a document with the serialized representation of contents in collection.

source

pub fn overwrite( collection: CollectionName, id: DocumentId, contents: impl Into<Bytes> ) -> Self

Overwrites a document in collection. If a document with id exists, it will be overwritten. If a document with id doesn’t exist, it will be created.

source

pub fn overwrite_serialized<C: SerializedCollection, Key>( id: &Key, contents: &C::Contents ) -> Result<Self, Error>
where Key: KeyEncoding<C::PrimaryKey> + ?Sized,

Overwrites a document with the serialized representation of contents in collection. If a document with id exists, it will be overwritten. If a document with id doesn’t exist, it will be created.

source

pub const fn delete(collection: CollectionName, header: Header) -> Self

Deletes a document from a collection.

source

pub const fn check_document_id_exists( collection: CollectionName, id: DocumentId ) -> Self

Check that the document id still exists in collection. If a document with that id is not present, the transaction will not be applied and Error::DocumentNotFound will be returned.

Upon success, OperationResult::Success will be included in the transaction’s results.

source

pub fn check_document_exists<C: Collection>( id: &C::PrimaryKey ) -> Result<Self, Error>

Check that the document id still exists in Collection C. If a document with that id is not present, the transaction will not be applied and Error::DocumentNotFound will be returned.

Upon success, OperationResult::Success will be included in the transaction’s results.

source

pub fn check_document_is_current<C: Collection, H: HasHeader>( doc_or_header: &H ) -> Result<Self, Error>

Check that the header of doc_or_header is the current revision of the stored document in Collection C. If a document with the header’s id is not present, the transaction will not be applied and Error::DocumentNotFound will be returned. If a document with the header’s id is present and the revision does not match, the transaction will not be applied and Error::DocumentConflict will be returned.

Upon success, OperationResult::Success will be included in the transaction’s results.

Trait Implementations§

source§

impl Clone for Operation

source§

fn clone(&self) -> Operation

Returns a copy 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 Operation

source§

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

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

impl<'de> Deserialize<'de> for Operation

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Operation> for Transaction

source§

fn from(operation: Operation) -> Self

Converts to this type from the input type.
source§

impl Serialize for Operation

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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.

§

impl<T> Instrument for T

§

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

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

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

§

type Output = T

Should always be Self
source§

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

§

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

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,