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§

§

impl Operation

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

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.

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

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.

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

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.

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

Updates a document in collection.

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

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

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

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.

pub fn overwrite_serialized<C, Key>( id: &Key, contents: &<C as SerializedCollection>::Contents ) -> Result<Operation, Error>where C: SerializedCollection, Key: KeyEncoding<<C as Collection>::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.

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

Deletes a document from a collection.

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

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.

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

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.

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

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§

§

impl Clone for Operation

§

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
§

impl Debug for Operation

§

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

Formats the value using the given formatter. Read more
§

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

§

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

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

impl From<Operation> for Transaction

§

fn from(operation: Operation) -> Transaction

Converts to this type from the input type.
§

impl Serialize for Operation

§

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

§

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

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