Struct tikv_client::Snapshot
source · pub struct Snapshot<Cod: Codec = ApiV1TxnCodec, PdC: PdClient<Codec = Cod> = PdRpcClient<Cod>> { /* private fields */ }
Expand description
A read-only transaction which reads at the given timestamp.
It behaves as if the snapshot was taken at the given timestamp, i.e. it can read operations happened before the timestamp, but ignores operations after the timestamp.
See the Transaction docs for more information on the methods.
Implementations§
source§impl<Cod: Codec, PdC: PdClient<Codec = Cod>> Snapshot<Cod, PdC>
impl<Cod: Codec, PdC: PdClient<Codec = Cod>> Snapshot<Cod, PdC>
sourcepub fn new(transaction: Transaction<Cod, PdC>) -> Self
pub fn new(transaction: Transaction<Cod, PdC>) -> Self
Constructs a new Snapshot
.
source§impl<Cod: Codec, PdC: PdClient<Codec = Cod>> Snapshot<Cod, PdC>
impl<Cod: Codec, PdC: PdClient<Codec = Cod>> Snapshot<Cod, PdC>
sourcepub async fn get(&mut self, key: impl Into<Key>) -> Result<Option<Value>>
pub async fn get(&mut self, key: impl Into<Key>) -> Result<Option<Value>>
Get the value associated with the given key.
sourcepub async fn key_exists(&mut self, key: impl Into<Key>) -> Result<bool>
pub async fn key_exists(&mut self, key: impl Into<Key>) -> Result<bool>
Check whether the key exists.
sourcepub async fn batch_get(
&mut self,
keys: impl IntoIterator<Item = impl Into<Key>>
) -> Result<impl Iterator<Item = KvPair>>
pub async fn batch_get( &mut self, keys: impl IntoIterator<Item = impl Into<Key>> ) -> Result<impl Iterator<Item = KvPair>>
Get the values associated with the given keys.
sourcepub async fn scan(
&mut self,
range: impl Into<BoundRange>,
limit: u32
) -> Result<impl Iterator<Item = KvPair>>
pub async fn scan( &mut self, range: impl Into<BoundRange>, limit: u32 ) -> Result<impl Iterator<Item = KvPair>>
Scan a range, return at most limit
key-value pairs that lying in the range.
sourcepub async fn scan_keys(
&mut self,
range: impl Into<BoundRange>,
limit: u32
) -> Result<impl Iterator<Item = Key>>
pub async fn scan_keys( &mut self, range: impl Into<BoundRange>, limit: u32 ) -> Result<impl Iterator<Item = Key>>
Scan a range, return at most limit
keys that lying in the range.
sourcepub async fn scan_reverse(
&mut self,
range: impl Into<BoundRange>,
limit: u32
) -> Result<impl Iterator<Item = KvPair>>
pub async fn scan_reverse( &mut self, range: impl Into<BoundRange>, limit: u32 ) -> Result<impl Iterator<Item = KvPair>>
Similar to scan, but in the reverse direction.
sourcepub async fn scan_keys_reverse(
&mut self,
range: impl Into<BoundRange>,
limit: u32
) -> Result<impl Iterator<Item = Key>>
pub async fn scan_keys_reverse( &mut self, range: impl Into<BoundRange>, limit: u32 ) -> Result<impl Iterator<Item = Key>>
Similar to scan_keys, but in the reverse direction.
Auto Trait Implementations§
impl<Cod, PdC> RefUnwindSafe for Snapshot<Cod, PdC>where Cod: RefUnwindSafe, PdC: RefUnwindSafe,
impl<Cod, PdC> Send for Snapshot<Cod, PdC>
impl<Cod, PdC> Sync for Snapshot<Cod, PdC>
impl<Cod, PdC> Unpin for Snapshot<Cod, PdC>where Cod: Unpin,
impl<Cod, PdC> UnwindSafe for Snapshot<Cod, PdC>where Cod: UnwindSafe, PdC: RefUnwindSafe,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request