Struct rusted_cypher::cypher::transaction::Transaction [] [src]

pub struct Transaction<'a, State: Any = Created> {
    // some fields omitted
}

Provides methods to interact with a transaction

This struct is used to begin a transaction, send queries, commit an rollback a transaction. Some methods are provided depending on the state of the transaction, for example, Transaction::begin is provided on a Created transaction and Transaction::commit is provided on Started transaction

Methods

impl<'a, State: Any> Transaction<'a, State>

fn add_statement<S: Into<Statement>>(&mut self, statement: S)

Adds a statement to the transaction

fn get_expires(&self) -> &Tm

Gets the expiration time of the transaction

impl<'a> Transaction<'a, Created>

fn new(endpoint: &str, headers: &'a Headers) -> Transaction<'a, Created>

fn with_statement<S: Into<Statement>>(self, statement: S) -> Self

Adds a statement to the transaction in builder style

fn begin(self) -> Result<(Transaction<'a, Started>, Vec<CypherResult>), GraphError>

Begins the transaction

Consumes the Transaction<Created> and returns the a Transaction<Started> alongside with the results of any Statement sent.

impl<'a> Transaction<'a, Started>

fn with_statement<S: Into<Statement>>(&mut self, statement: S) -> &mut Self

Adds a statement to the transaction in builder style

fn exec<S: Into<Statement>>(&mut self, statement: S) -> Result<CypherResult, GraphError>

Executes the given statement

Any statements added via add_statement or with_statement will be discarded

fn send(&mut self) -> Result<Vec<CypherResult>, GraphError>

Executes the statements added via add_statement or with_statement

fn commit(self) -> Result<Vec<CypherResult>, GraphError>

Commits the transaction, returning the results

fn rollback(self) -> Result<(), GraphError>

Rollback the transaction

fn reset_timeout(&mut self) -> Result<(), GraphError>

Sends a query to just reset the transaction timeout

All transactions have a timeout. Use this method to keep a transaction alive.