@@ -17,12 +17,14 @@ pub(super) trait Decode<'a, 's, S>: Sized {
1717macro_rules! rpc_encode_decode {
1818 ( le $ty: ty) => {
1919 impl <S > Encode <S > for $ty {
20+ #[ inline]
2021 fn encode( self , w: & mut Buffer , _: & mut S ) {
2122 w. extend_from_array( & self . to_le_bytes( ) ) ;
2223 }
2324 }
2425
2526 impl <S > Decode <' _, ' _, S > for $ty {
27+ #[ inline]
2628 fn decode( r: & mut & [ u8 ] , _: & mut S ) -> Self {
2729 const N : usize = size_of:: <$ty>( ) ;
2830
@@ -44,6 +46,7 @@ macro_rules! rpc_encode_decode {
4446 impl <' a, S , $( $( $T: for <' s> Decode <' a, ' s, S >) ,+) ?> Decode <' a, ' _, S >
4547 for $name $( <$( $T) ,+>) ?
4648 {
49+ #[ inline]
4750 fn decode( r: & mut & ' a [ u8 ] , s: & mut S ) -> Self {
4851 $name {
4952 $( $field: Decode :: decode( r, s) ) ,*
@@ -59,6 +62,7 @@ macro_rules! rpc_encode_decode {
5962 $( const $variant: u8 = Tag :: $variant as u8 ; ) *
6063
6164 impl <S , $( $( $T: Encode <S >) ,+) ?> Encode <S > for $name $( <$( $T) ,+>) ? {
65+ #[ inline]
6266 fn encode( self , w: & mut Buffer , s: & mut S ) {
6367 match self {
6468 $( $name:: $variant $( ( $field) ) * => {
@@ -72,6 +76,7 @@ macro_rules! rpc_encode_decode {
7276 impl <' a, S , $( $( $T: for <' s> Decode <' a, ' s, S >) ,+) ?> Decode <' a, ' _, S >
7377 for $name $( <$( $T) ,+>) ?
7478 {
79+ #[ inline]
7580 fn decode( r: & mut & ' a [ u8 ] , s: & mut S ) -> Self {
7681 match u8 :: decode( r, s) {
7782 $( $variant => {
@@ -87,20 +92,24 @@ macro_rules! rpc_encode_decode {
8792}
8893
8994impl < S > Encode < S > for ( ) {
95+ #[ inline]
9096 fn encode ( self , _: & mut Buffer , _: & mut S ) { }
9197}
9298
9399impl < S > Decode < ' _ , ' _ , S > for ( ) {
100+ #[ inline]
94101 fn decode ( _: & mut & [ u8 ] , _: & mut S ) -> Self { }
95102}
96103
97104impl < S > Encode < S > for u8 {
105+ #[ inline]
98106 fn encode ( self , w : & mut Buffer , _: & mut S ) {
99107 w. push ( self ) ;
100108 }
101109}
102110
103111impl < S > Decode < ' _ , ' _ , S > for u8 {
112+ #[ inline]
104113 fn decode ( r : & mut & [ u8 ] , _: & mut S ) -> Self {
105114 let x = r[ 0 ] ;
106115 * r = & r[ 1 ..] ;
@@ -117,6 +126,7 @@ const MAX_USIZE_SIZE: usize = 8;
117126
118127#[ cfg( not( target_pointer_width = "64" ) ) ]
119128impl < S > Encode < S > for usize {
129+ #[ inline]
120130 fn encode ( self , w : & mut Buffer , _: & mut S ) {
121131 const N : usize = size_of :: < usize > ( ) ;
122132
@@ -131,6 +141,7 @@ impl<S> Encode<S> for usize {
131141
132142#[ cfg( not( target_pointer_width = "64" ) ) ]
133143impl < S > Decode < ' _ , ' _ , S > for usize {
144+ #[ inline]
134145 fn decode ( r : & mut & [ u8 ] , _: & mut S ) -> Self {
135146 const N : usize = size_of :: < usize > ( ) ;
136147 const {
@@ -146,12 +157,14 @@ impl<S> Decode<'_, '_, S> for usize {
146157}
147158
148159impl < S > Encode < S > for bool {
160+ #[ inline]
149161 fn encode ( self , w : & mut Buffer , s : & mut S ) {
150162 ( self as u8 ) . encode ( w, s) ;
151163 }
152164}
153165
154166impl < S > Decode < ' _ , ' _ , S > for bool {
167+ #[ inline]
155168 fn decode ( r : & mut & [ u8 ] , s : & mut S ) -> Self {
156169 match u8:: decode ( r, s) {
157170 0 => false ,
@@ -162,18 +175,21 @@ impl<S> Decode<'_, '_, S> for bool {
162175}
163176
164177impl < S > Encode < S > for NonZero < u32 > {
178+ #[ inline]
165179 fn encode ( self , w : & mut Buffer , s : & mut S ) {
166180 self . get ( ) . encode ( w, s) ;
167181 }
168182}
169183
170184impl < S > Decode < ' _ , ' _ , S > for NonZero < u32 > {
185+ #[ inline]
171186 fn decode ( r : & mut & [ u8 ] , s : & mut S ) -> Self {
172187 Self :: new ( u32:: decode ( r, s) ) . unwrap ( )
173188 }
174189}
175190
176191impl < S , A : Encode < S > , B : Encode < S > > Encode < S > for ( A , B ) {
192+ #[ inline]
177193 fn encode ( self , w : & mut Buffer , s : & mut S ) {
178194 self . 0 . encode ( w, s) ;
179195 self . 1 . encode ( w, s) ;
@@ -183,12 +199,14 @@ impl<S, A: Encode<S>, B: Encode<S>> Encode<S> for (A, B) {
183199impl < ' a , S , A : for < ' s > Decode < ' a , ' s , S > , B : for < ' s > Decode < ' a , ' s , S > > Decode < ' a , ' _ , S >
184200 for ( A , B )
185201{
202+ #[ inline]
186203 fn decode ( r : & mut & ' a [ u8 ] , s : & mut S ) -> Self {
187204 ( Decode :: decode ( r, s) , Decode :: decode ( r, s) )
188205 }
189206}
190207
191208impl < S > Encode < S > for & str {
209+ #[ inline]
192210 fn encode ( self , w : & mut Buffer , s : & mut S ) {
193211 let bytes = self . as_bytes ( ) ;
194212 bytes. len ( ) . encode ( w, s) ;
@@ -197,6 +215,7 @@ impl<S> Encode<S> for &str {
197215}
198216
199217impl < ' a , S > Decode < ' a , ' _ , S > for & ' a str {
218+ #[ inline]
200219 fn decode ( r : & mut & ' a [ u8 ] , s : & mut S ) -> Self {
201220 let len = usize:: decode ( r, s) ;
202221 let xs = & r[ ..len] ;
@@ -206,18 +225,21 @@ impl<'a, S> Decode<'a, '_, S> for &'a str {
206225}
207226
208227impl < S > Encode < S > for String {
228+ #[ inline]
209229 fn encode ( self , w : & mut Buffer , s : & mut S ) {
210230 self [ ..] . encode ( w, s) ;
211231 }
212232}
213233
214234impl < S > Decode < ' _ , ' _ , S > for String {
235+ #[ inline]
215236 fn decode ( r : & mut & [ u8 ] , s : & mut S ) -> Self {
216237 <& str >:: decode ( r, s) . to_string ( )
217238 }
218239}
219240
220241impl < S , T : Encode < S > > Encode < S > for Vec < T > {
242+ #[ inline]
221243 fn encode ( self , w : & mut Buffer , s : & mut S ) {
222244 self . len ( ) . encode ( w, s) ;
223245 for x in self {
@@ -227,6 +249,7 @@ impl<S, T: Encode<S>> Encode<S> for Vec<T> {
227249}
228250
229251impl < ' a , S , T : for < ' s > Decode < ' a , ' s , S > > Decode < ' a , ' _ , S > for Vec < T > {
252+ #[ inline]
230253 fn decode ( r : & mut & ' a [ u8 ] , s : & mut S ) -> Self {
231254 let len = usize:: decode ( r, s) ;
232255 let mut vec = Vec :: with_capacity ( len) ;
@@ -289,12 +312,14 @@ impl PanicMessage {
289312}
290313
291314impl < S > Encode < S > for PanicMessage {
315+ #[ inline]
292316 fn encode ( self , w : & mut Buffer , s : & mut S ) {
293317 self . as_str ( ) . encode ( w, s) ;
294318 }
295319}
296320
297321impl < S > Decode < ' _ , ' _ , S > for PanicMessage {
322+ #[ inline]
298323 fn decode ( r : & mut & [ u8 ] , s : & mut S ) -> Self {
299324 match Option :: < String > :: decode ( r, s) {
300325 Some ( s) => PanicMessage :: String ( s) ,
0 commit comments