pub struct Command {
pub command_type: CommandType,
pub key: String,
pub value: Option<Vec<u8>>,
pub metadata: HashMap<String, String>,
}Expand description
A command to be applied to the state machine. Supports both key-value and database operations.
Fields§
§command_type: CommandType§key: String§value: Option<Vec<u8>>§metadata: HashMap<String, String>Implementations§
Source§impl Command
impl Command
Sourcepub fn document_insert(collection: impl Into<String>, document: Vec<u8>) -> Self
pub fn document_insert(collection: impl Into<String>, document: Vec<u8>) -> Self
Create a document insert command.
Sourcepub fn document_update(
collection: impl Into<String>,
doc_id: impl Into<String>,
document: Vec<u8>,
) -> Self
pub fn document_update( collection: impl Into<String>, doc_id: impl Into<String>, document: Vec<u8>, ) -> Self
Create a document update command.
Sourcepub fn document_delete(
collection: impl Into<String>,
doc_id: impl Into<String>,
) -> Self
pub fn document_delete( collection: impl Into<String>, doc_id: impl Into<String>, ) -> Self
Create a document delete command.
Sourcepub fn graph_create_node(label: impl Into<String>, properties: Vec<u8>) -> Self
pub fn graph_create_node(label: impl Into<String>, properties: Vec<u8>) -> Self
Create a graph node create command.
Sourcepub fn graph_create_edge(
edge_type: impl Into<String>,
from_node: impl Into<String>,
to_node: impl Into<String>,
properties: Vec<u8>,
) -> Self
pub fn graph_create_edge( edge_type: impl Into<String>, from_node: impl Into<String>, to_node: impl Into<String>, properties: Vec<u8>, ) -> Self
Create a graph edge create command.
Sourcepub fn tx_rollback(tx_id: u64) -> Self
pub fn tx_rollback(tx_id: u64) -> Self
Create a transaction rollback command.
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
Deserialize a command.
Sourcepub fn sql_statement(&self) -> Option<&str>
pub fn sql_statement(&self) -> Option<&str>
Get the SQL statement if this is a SQL command.
Sourcepub fn transaction_id(&self) -> Option<u64>
pub fn transaction_id(&self) -> Option<u64>
Get the transaction ID if this is a transaction command.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Command
impl<'de> Deserialize<'de> for Command
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnsafeUnpin for Command
impl UnwindSafe for Command
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
Mutably borrows from an owned value. Read more