@@ -72,20 +72,20 @@ impl ChunkedEncoder {
72
72
buf : & mut [ u8 ] ,
73
73
) -> Poll < io:: Result < usize > > {
74
74
self . bytes_written = 0 ;
75
- let res = self . dispatch ( res, cx, buf) ;
75
+ let res = self . run ( res, cx, buf) ;
76
76
log:: trace!( "ChunkedEncoder {} bytes written" , self . bytes_written) ;
77
77
res
78
78
}
79
79
80
80
/// Execute the right method for the current state.
81
- fn dispatch (
81
+ fn run (
82
82
& mut self ,
83
83
res : & mut Response ,
84
84
cx : & mut Context < ' _ > ,
85
85
buf : & mut [ u8 ] ,
86
86
) -> Poll < io:: Result < usize > > {
87
87
match self . state {
88
- State :: Start => self . set_state ( State :: EncodeChunks , res, cx, buf) ,
88
+ State :: Start => self . dispatch ( State :: EncodeChunks , res, cx, buf) ,
89
89
State :: EncodeChunks => self . encode_chunks ( res, cx, buf) ,
90
90
State :: EndOfChunks => self . encode_chunks_eos ( res, cx, buf) ,
91
91
State :: ReceiveTrailers => self . receive_trailers ( res, cx, buf) ,
@@ -96,7 +96,7 @@ impl ChunkedEncoder {
96
96
}
97
97
98
98
/// Switch the internal state to a new state.
99
- fn set_state (
99
+ fn dispatch (
100
100
& mut self ,
101
101
state : State ,
102
102
res : & mut Response ,
@@ -118,7 +118,7 @@ impl ChunkedEncoder {
118
118
}
119
119
120
120
self . state = state;
121
- self . dispatch ( res, cx, buf)
121
+ self . run ( res, cx, buf)
122
122
}
123
123
124
124
/// Stream out data using chunked encoding.
@@ -142,7 +142,7 @@ impl ChunkedEncoder {
142
142
// If the stream doesn't have any more bytes left to read we're done
143
143
// sending chunks and it's time to move on.
144
144
if src. len ( ) == 0 {
145
- return self . set_state ( State :: EndOfChunks , res, cx, buf) ;
145
+ return self . dispatch ( State :: EndOfChunks , res, cx, buf) ;
146
146
}
147
147
148
148
// Each chunk is prefixed with the length of the data in hex, then a
@@ -209,7 +209,7 @@ impl ChunkedEncoder {
209
209
buf[ idx + 2 ] = LF ;
210
210
self . bytes_written += 1 + CRLF_LEN ;
211
211
212
- self . set_state ( State :: ReceiveTrailers , res, cx, buf)
212
+ self . dispatch ( State :: ReceiveTrailers , res, cx, buf)
213
213
}
214
214
215
215
/// Receive trailers sent to the response, and store them in an internal
@@ -221,7 +221,7 @@ impl ChunkedEncoder {
221
221
buf : & mut [ u8 ] ,
222
222
) -> Poll < io:: Result < usize > > {
223
223
// TODO: actually wait for trailers to be received.
224
- self . set_state ( State :: EncodeTrailers , res, cx, buf)
224
+ self . dispatch ( State :: EncodeTrailers , res, cx, buf)
225
225
}
226
226
227
227
/// Send trailers to the buffer.
@@ -232,7 +232,7 @@ impl ChunkedEncoder {
232
232
buf : & mut [ u8 ] ,
233
233
) -> Poll < io:: Result < usize > > {
234
234
// TODO: actually encode trailers here.
235
- self . set_state ( State :: EndOfStream , res, cx, buf)
235
+ self . dispatch ( State :: EndOfStream , res, cx, buf)
236
236
}
237
237
238
238
/// Encode the end of the stream.
@@ -247,6 +247,6 @@ impl ChunkedEncoder {
247
247
buf[ idx] = CR ;
248
248
buf[ idx + 1 ] = LF ;
249
249
self . bytes_written += CRLF_LEN ;
250
- self . set_state ( State :: End , res, cx, buf)
250
+ self . dispatch ( State :: End , res, cx, buf)
251
251
}
252
252
}
0 commit comments