@@ -8,7 +8,6 @@ use std::{fmt, sync::Arc, time::Duration};
8
8
use futures:: Future ;
9
9
use grpcio:: { CallOption , Environment } ;
10
10
use kvproto:: { errorpb, kvrpcpb, tikvpb:: TikvClient } ;
11
- use protobuf:: { self , Message } ;
12
11
13
12
use crate :: {
14
13
rpc:: {
@@ -160,7 +159,7 @@ has_no_error!(kvrpcpb::RawBatchScanResponse);
160
159
161
160
macro_rules! raw_request {
162
161
( $context: expr, $type: ty) => { {
163
- let mut req = <$type>:: new ( ) ;
162
+ let mut req = <$type>:: default ( ) ;
164
163
let ( region, cf) = $context. into_inner( ) ;
165
164
req. set_context( region. into( ) ) ;
166
165
if let Some ( cf) = cf {
@@ -172,15 +171,15 @@ macro_rules! raw_request {
172
171
173
172
macro_rules! txn_request {
174
173
( $context: expr, $type: ty) => { {
175
- let mut req = <$type>:: new ( ) ;
174
+ let mut req = <$type>:: default ( ) ;
176
175
req. set_context( $context. into_inner( ) . into( ) ) ;
177
176
req
178
177
} } ;
179
178
}
180
179
181
180
impl From < Mutation > for kvrpcpb:: Mutation {
182
181
fn from ( mutation : Mutation ) -> kvrpcpb:: Mutation {
183
- let mut pb = kvrpcpb:: Mutation :: new ( ) ;
182
+ let mut pb = kvrpcpb:: Mutation :: default ( ) ;
184
183
match mutation {
185
184
Mutation :: Put ( k, v) => {
186
185
pb. set_op ( kvrpcpb:: Op :: Put ) ;
@@ -206,7 +205,7 @@ impl From<Mutation> for kvrpcpb::Mutation {
206
205
207
206
impl From < TxnInfo > for kvrpcpb:: TxnInfo {
208
207
fn from ( txn_info : TxnInfo ) -> kvrpcpb:: TxnInfo {
209
- let mut pb = kvrpcpb:: TxnInfo :: new ( ) ;
208
+ let mut pb = kvrpcpb:: TxnInfo :: default ( ) ;
210
209
pb. set_txn ( txn_info. txn ) ;
211
210
pb. set_status ( txn_info. status ) ;
212
211
pb
@@ -317,7 +316,7 @@ impl KvClient {
317
316
mutations : impl Iterator < Item = Mutation > ,
318
317
commit_version : u64 ,
319
318
) -> impl Future < Item = kvrpcpb:: ImportResponse , Error = Error > {
320
- let mut req = kvrpcpb:: ImportRequest :: new ( ) ;
319
+ let mut req = kvrpcpb:: ImportRequest :: default ( ) ;
321
320
req. set_mutations ( mutations. map ( Into :: into) . collect ( ) ) ;
322
321
req. set_commit_version ( commit_version) ;
323
322
@@ -624,7 +623,7 @@ impl KvClient {
624
623
625
624
#[ inline]
626
625
fn convert_to_grpc_pair ( pair : KvPair ) -> kvrpcpb:: KvPair {
627
- let mut result = kvrpcpb:: KvPair :: new ( ) ;
626
+ let mut result = kvrpcpb:: KvPair :: default ( ) ;
628
627
let ( key, value) = pair. into_inner ( ) ;
629
628
result. set_key ( key. into_inner ( ) ) ;
630
629
result. set_value ( value. into_inner ( ) ) ;
@@ -652,7 +651,7 @@ impl KvClient {
652
651
#[ inline]
653
652
fn convert_to_grpc_range ( range : ( Option < Key > , Option < Key > ) ) -> kvrpcpb:: KeyRange {
654
653
let ( start, end) = range;
655
- let mut range = kvrpcpb:: KeyRange :: new ( ) ;
654
+ let mut range = kvrpcpb:: KeyRange :: default ( ) ;
656
655
start. map ( |k| range. set_start_key ( k. into_inner ( ) ) ) . unwrap ( ) ;
657
656
end. map ( |k| range. set_end_key ( k. into_inner ( ) ) ) . unwrap ( ) ;
658
657
range
0 commit comments