diff --git a/src/transaction/client.rs b/src/transaction/client.rs index 25acbb3..bed7da6 100644 --- a/src/transaction/client.rs +++ b/src/transaction/client.rs @@ -12,7 +12,7 @@ use std::pin::Pin; pub struct Client; impl Client { - /// Create a new [`Client`](Client) once the [`Connect`](Connect) resolves. + /// Creates a new [`Client`](Client) once the [`Connect`](Connect) resolves. /// /// ```rust,no_run /// # #![feature(async_await)] @@ -27,7 +27,7 @@ impl Client { Connect::new(config) } - /// Create a new [`Transaction`](Transaction) using the timestamp from [`current_timestamp`](Client::current_timestamp). + /// Creates a new [`Transaction`](Transaction). /// /// Using the transaction you can issue commands like [`get`](Transaction::get) or [`set`](Transaction::set). /// @@ -48,27 +48,7 @@ impl Client { unimplemented!() } - /// Create a new [`Transaction`](Transaction) at the provded timestamp. - /// - /// ```rust,no_run - /// # #![feature(async_await)] - /// use tikv_client::{Config, transaction::Client}; - /// use futures::prelude::*; - /// # futures::executor::block_on(async { - /// let connect = Client::connect(Config::default()); - /// let client = connect.await.unwrap(); - /// let timestamp = client.current_timestamp(); - /// let transaction = client.begin_with_timestamp(timestamp); - /// // ... Issue some commands. - /// let commit = transaction.commit(); - /// let result: () = commit.await.unwrap(); - /// # }); - /// ``` - pub fn begin_with_timestamp(&self, _timestamp: Timestamp) -> Transaction { - unimplemented!() - } - - /// Get a [`Snapshot`](Snapshot) using the timestamp from [`current_timestamp`](Client::current_timestamp). + /// Gets the latest [`Snapshot`](Snapshot). /// /// ```rust,no_run /// # #![feature(async_await)] @@ -85,7 +65,24 @@ impl Client { unimplemented!() } - /// Retrieve the current [`Timestamp`](Timestamp). + /// Gets a [`Snapshot`](Snapshot) at the given point in time. + /// + /// ```rust,no_run + /// # #![feature(async_await)] + /// use tikv_client::{Config, transaction::Client}; + /// use futures::prelude::*; + /// # futures::executor::block_on(async { + /// let connect = Client::connect(Config::default()); + /// let client = connect.await.unwrap(); + /// let snapshot = client.snapshot(); + /// // ... Issue some commands. + /// # }); + /// ``` + pub fn snapshot_at(&self, timestamp: Timestamp) -> Snapshot { + unimplemented!() + } + + /// Retrieves the current [`Timestamp`](Timestamp). /// /// ```rust,no_run /// # #![feature(async_await)] diff --git a/src/transaction/transaction.rs b/src/transaction/transaction.rs index d3512db..3413e0d 100644 --- a/src/transaction/transaction.rs +++ b/src/transaction/transaction.rs @@ -257,7 +257,9 @@ pub struct TxnInfo { } /// A snapshot of dataset at a particular point in time. -pub struct Snapshot; +pub struct Snapshot { + timestamp: Timestamp, +} impl Snapshot { pub fn get(&self, key: impl Into) -> Get {