@@ -8,7 +8,6 @@ use std::{fmt, sync::Arc, time::Duration};
88use futures:: Future ;
99use grpcio:: { CallOption , Environment } ;
1010use kvproto:: { errorpb, kvrpcpb, tikvpb:: TikvClient } ;
11- use protobuf:: { self , Message } ;
1211
1312use crate :: {
1413 rpc:: {
@@ -160,7 +159,7 @@ has_no_error!(kvrpcpb::RawBatchScanResponse);
160159
161160macro_rules! raw_request {
162161 ( $context: expr, $type: ty) => { {
163- let mut req = <$type>:: new ( ) ;
162+ let mut req = <$type>:: default ( ) ;
164163 let ( region, cf) = $context. into_inner( ) ;
165164 req. set_context( region. into( ) ) ;
166165 if let Some ( cf) = cf {
@@ -172,15 +171,15 @@ macro_rules! raw_request {
172171
173172macro_rules! txn_request {
174173 ( $context: expr, $type: ty) => { {
175- let mut req = <$type>:: new ( ) ;
174+ let mut req = <$type>:: default ( ) ;
176175 req. set_context( $context. into_inner( ) . into( ) ) ;
177176 req
178177 } } ;
179178}
180179
181180impl From < Mutation > for kvrpcpb:: Mutation {
182181 fn from ( mutation : Mutation ) -> kvrpcpb:: Mutation {
183- let mut pb = kvrpcpb:: Mutation :: new ( ) ;
182+ let mut pb = kvrpcpb:: Mutation :: default ( ) ;
184183 match mutation {
185184 Mutation :: Put ( k, v) => {
186185 pb. set_op ( kvrpcpb:: Op :: Put ) ;
@@ -206,7 +205,7 @@ impl From<Mutation> for kvrpcpb::Mutation {
206205
207206impl From < TxnInfo > for kvrpcpb:: TxnInfo {
208207 fn from ( txn_info : TxnInfo ) -> kvrpcpb:: TxnInfo {
209- let mut pb = kvrpcpb:: TxnInfo :: new ( ) ;
208+ let mut pb = kvrpcpb:: TxnInfo :: default ( ) ;
210209 pb. set_txn ( txn_info. txn ) ;
211210 pb. set_status ( txn_info. status ) ;
212211 pb
@@ -317,7 +316,7 @@ impl KvClient {
317316 mutations : impl Iterator < Item = Mutation > ,
318317 commit_version : u64 ,
319318 ) -> impl Future < Item = kvrpcpb:: ImportResponse , Error = Error > {
320- let mut req = kvrpcpb:: ImportRequest :: new ( ) ;
319+ let mut req = kvrpcpb:: ImportRequest :: default ( ) ;
321320 req. set_mutations ( mutations. map ( Into :: into) . collect ( ) ) ;
322321 req. set_commit_version ( commit_version) ;
323322
@@ -624,7 +623,7 @@ impl KvClient {
624623
625624 #[ inline]
626625 fn convert_to_grpc_pair ( pair : KvPair ) -> kvrpcpb:: KvPair {
627- let mut result = kvrpcpb:: KvPair :: new ( ) ;
626+ let mut result = kvrpcpb:: KvPair :: default ( ) ;
628627 let ( key, value) = pair. into_inner ( ) ;
629628 result. set_key ( key. into_inner ( ) ) ;
630629 result. set_value ( value. into_inner ( ) ) ;
@@ -652,7 +651,7 @@ impl KvClient {
652651 #[ inline]
653652 fn convert_to_grpc_range ( range : ( Option < Key > , Option < Key > ) ) -> kvrpcpb:: KeyRange {
654653 let ( start, end) = range;
655- let mut range = kvrpcpb:: KeyRange :: new ( ) ;
654+ let mut range = kvrpcpb:: KeyRange :: default ( ) ;
656655 start. map ( |k| range. set_start_key ( k. into_inner ( ) ) ) . unwrap ( ) ;
657656 end. map ( |k| range. set_end_key ( k. into_inner ( ) ) ) . unwrap ( ) ;
658657 range
0 commit comments