Skip to content

Commit 182a457

Browse files
committed
bound Client to right codec
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
1 parent 0ed902d commit 182a457

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/raw/client.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ use crate::{
1313
config::Config,
1414
pd::{PdClient, PdRpcClient},
1515
raw::lowering::*,
16-
request::{
17-
codec::{RawCodec, RequestCodec},
18-
Collect, CollectSingle, Plan,
19-
},
16+
request::{codec::RawCodec, Collect, CollectSingle, Plan},
2017
Backoff, BoundRange, ColumnFamily, Key, KvPair, Result, Value,
2118
};
2219

@@ -29,7 +26,7 @@ const MAX_RAW_KV_SCAN_LIMIT: u32 = 10240;
2926
///
3027
/// The returned results of raw request methods are [`Future`](std::future::Future)s that must be
3128
/// awaited to execute.
32-
pub struct Client<C, PdC: PdClient = PdRpcClient<C>> {
29+
pub struct Client<C: RawCodec, PdC: PdClient = PdRpcClient<C>> {
3330
rpc: Arc<PdC>,
3431
cf: Option<ColumnFamily>,
3532
/// Whether to use the [`atomic mode`](Client::with_atomic_for_cas).
@@ -38,7 +35,7 @@ pub struct Client<C, PdC: PdClient = PdRpcClient<C>> {
3835
_phantom: PhantomData<C>,
3936
}
4037

41-
impl<C: RequestCodec> Clone for Client<C> {
38+
impl<C: RawCodec> Clone for Client<C> {
4239
fn clone(&self) -> Self {
4340
Self {
4441
rpc: self.rpc.clone(),

src/request/codec.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,7 @@ impl<M: Mode> RequestCodec for ApiV2<M> {
359359
req.decode_response(self, resp)
360360
}
361361
}
362+
363+
impl RawCodec for ApiV2<RawMode> {}
364+
365+
impl TxnCodec for ApiV2<TxnMode> {}

src/transaction/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ const SCAN_LOCK_BATCH_SIZE: u32 = 1024;
3737
///
3838
/// The returned results of transactional requests are [`Future`](std::future::Future)s that must be
3939
/// awaited to execute.
40-
pub struct Client<C> {
40+
pub struct Client<C: TxnCodec> {
4141
pd: Arc<PdRpcClient<C>>,
4242
logger: Logger,
4343
_phantom: PhantomData<C>,
4444
}
4545

46-
impl<C> Clone for Client<C> {
46+
impl<C: TxnCodec> Clone for Client<C> {
4747
fn clone(&self) -> Self {
4848
Self {
4949
pd: self.pd.clone(),

0 commit comments

Comments
 (0)