44//! types (i.e., the types from the client crate) and converts these to the types used in the
55//! generated protobuf code, then calls the low-level ctor functions in the requests module.
66
7- use std:: { iter:: Iterator , ops:: Range , sync:: Arc } ;
8- use std:: marker:: PhantomData ;
7+ use std:: { iter:: Iterator , marker:: PhantomData , ops:: Range , sync:: Arc } ;
98
109use tikv_client_proto:: { kvrpcpb, metapb} ;
1110
12- use crate :: { BoundRange , ColumnFamily , Key , KvPair , raw:: requests, Value } ;
13- use crate :: request:: KvRequest ;
14- use crate :: request:: request_codec:: RequestCodec ;
11+ use crate :: {
12+ raw:: requests,
13+ request:: { request_codec:: RequestCodec , KvRequest } ,
14+ BoundRange , ColumnFamily , Key , KvPair , Value ,
15+ } ;
1516
16- pub fn new_raw_get_request < C : RequestCodec > ( key : Key , cf : Option < ColumnFamily > ) -> kvrpcpb:: RawGetRequest {
17+ pub fn new_raw_get_request < C : RequestCodec > (
18+ key : Key ,
19+ cf : Option < ColumnFamily > ,
20+ ) -> kvrpcpb:: RawGetRequest {
1721 requests:: new_raw_get_request :: < C > ( key. into ( ) , cf)
1822}
1923
20- pub fn new_raw_batch_get_request < C : RequestCodec > (
21- keys : impl Iterator < Item = Key > ,
24+ pub fn new_raw_batch_get_request < C : RequestCodec > (
25+ keys : impl Iterator < Item = Key > ,
2226 cf : Option < ColumnFamily > ,
2327) -> kvrpcpb:: RawBatchGetRequest {
2428 requests:: new_raw_batch_get_request :: < C > ( keys. map ( Into :: into) . collect ( ) , cf)
2529}
2630
27- pub fn new_raw_put_request < C : RequestCodec > (
31+ pub fn new_raw_put_request < C : RequestCodec > (
2832 key : Key ,
2933 value : Value ,
3034 cf : Option < ColumnFamily > ,
@@ -33,43 +37,47 @@ pub fn new_raw_put_request<C:RequestCodec>(
3337 requests:: new_raw_put_request :: < C > ( key. into ( ) , value, cf, atomic)
3438}
3539
36- pub fn new_raw_batch_put_request < C : RequestCodec > (
37- pairs : impl Iterator < Item = KvPair > ,
40+ pub fn new_raw_batch_put_request < C : RequestCodec > (
41+ pairs : impl Iterator < Item = KvPair > ,
3842 cf : Option < ColumnFamily > ,
3943 atomic : bool ,
4044) -> kvrpcpb:: RawBatchPutRequest {
4145 requests:: new_raw_batch_put_request :: < C > ( pairs. map ( Into :: into) . collect ( ) , cf, atomic)
4246}
4347
44- pub fn new_raw_delete_request < C : RequestCodec > (
48+ pub fn new_raw_delete_request < C : RequestCodec > (
4549 key : Key ,
4650 cf : Option < ColumnFamily > ,
4751 atomic : bool ,
4852) -> kvrpcpb:: RawDeleteRequest {
4953 requests:: new_raw_delete_request :: < C > ( key. into ( ) , cf, atomic)
5054}
5155
52- pub fn new_raw_batch_delete_request < C : RequestCodec > (
53- keys : impl Iterator < Item = Key > ,
56+ pub fn new_raw_batch_delete_request < C : RequestCodec > (
57+ keys : impl Iterator < Item = Key > ,
5458 cf : Option < ColumnFamily > ,
5559) -> kvrpcpb:: RawBatchDeleteRequest {
5660 requests:: new_raw_batch_delete_request :: < C > ( keys. map ( Into :: into) . collect ( ) , cf)
5761}
5862
59- pub fn new_raw_delete_range_request < C : RequestCodec > (
63+ pub fn new_raw_delete_range_request < C : RequestCodec > (
6064 range : BoundRange ,
6165 cf : Option < ColumnFamily > ,
6266) -> kvrpcpb:: RawDeleteRangeRequest {
6367 let ( start_key, end_key) = range. into_keys ( ) ;
64- requests:: new_raw_delete_range_request :: < C > ( start_key. into ( ) , end_key. unwrap_or_default ( ) . into ( ) , cf)
68+ requests:: new_raw_delete_range_request :: < C > (
69+ start_key. into ( ) ,
70+ end_key. unwrap_or_default ( ) . into ( ) ,
71+ cf,
72+ )
6573}
6674
67- pub fn new_raw_scan_request < C : RequestCodec > (
75+ pub fn new_raw_scan_request < C : RequestCodec > (
6876 range : BoundRange ,
6977 limit : u32 ,
7078 key_only : bool ,
7179 cf : Option < ColumnFamily > ,
72- ) -> kvrpcpb:: RawScanRequest {
80+ ) -> kvrpcpb:: RawScanRequest {
7381 let ( start_key, end_key) = range. into_keys ( ) ;
7482 requests:: new_raw_scan_request :: < C > (
7583 start_key. into ( ) ,
@@ -80,16 +88,21 @@ pub fn new_raw_scan_request<C:RequestCodec>(
8088 )
8189}
8290
83- pub fn new_raw_batch_scan_request < C : RequestCodec > (
84- ranges : impl Iterator < Item = BoundRange > ,
91+ pub fn new_raw_batch_scan_request < C : RequestCodec > (
92+ ranges : impl Iterator < Item = BoundRange > ,
8593 each_limit : u32 ,
8694 key_only : bool ,
8795 cf : Option < ColumnFamily > ,
8896) -> kvrpcpb:: RawBatchScanRequest {
89- requests:: new_raw_batch_scan_request :: < C > ( ranges. map ( Into :: into) . collect ( ) , each_limit, key_only, cf)
97+ requests:: new_raw_batch_scan_request :: < C > (
98+ ranges. map ( Into :: into) . collect ( ) ,
99+ each_limit,
100+ key_only,
101+ cf,
102+ )
90103}
91104
92- pub fn new_cas_request < C : RequestCodec > (
105+ pub fn new_cas_request < C : RequestCodec > (
93106 key : Key ,
94107 value : Value ,
95108 previous_value : Option < Value > ,
@@ -98,10 +111,10 @@ pub fn new_cas_request<C:RequestCodec>(
98111 requests:: new_cas_request :: < C > ( key. into ( ) , value, previous_value, cf)
99112}
100113
101- pub fn new_raw_coprocessor_request < C : RequestCodec > (
114+ pub fn new_raw_coprocessor_request < C : RequestCodec > (
102115 copr_name : String ,
103116 copr_version_req : String ,
104- ranges : impl Iterator < Item = BoundRange > ,
117+ ranges : impl Iterator < Item = BoundRange > ,
105118 request_builder : impl Fn ( metapb:: Region , Vec < Range < Key > > ) -> Vec < u8 > + Send + Sync + ' static ,
106119) -> requests:: RawCoprocessorRequest {
107120 requests:: new_raw_coprocessor_request :: < C > (
0 commit comments