@@ -4,7 +4,7 @@ use crate::decode::rangecoder::RangeDecoder;
44use crate :: decompress:: Options ;
55use crate :: error:: Error ;
66use std:: fmt:: Debug ;
7- use std:: io:: { BufRead , Cursor , Read , Write } ;
7+ use std:: io:: { self , BufRead , Cursor , Read , Write } ;
88
99/// Minimum header length to be read.
1010/// - props: u8 (1 byte)
5959}
6060
6161/// Lzma decompressor that can process multiple chunks of data using the
62- /// `std:: io::Write` interface.
62+ /// `io::Write` interface.
6363pub struct Stream < W >
6464where
6565 W : Write ,
@@ -78,13 +78,13 @@ where
7878 W : Write ,
7979{
8080 /// Initialize the stream. This will consume the `output` which is the sink
81- /// implementing `std:: io::Write` that will receive decompressed bytes.
81+ /// implementing `io::Write` that will receive decompressed bytes.
8282 pub fn new ( output : W ) -> Self {
8383 Self :: new_with_options ( & Options :: default ( ) , output)
8484 }
8585
8686 /// Initialize the stream with the given `options`. This will consume the
87- /// `output` which is the sink implementing `std:: io::Write` that will
87+ /// `output` which is the sink implementing `io::Write` that will
8888 /// receive decompressed bytes.
8989 pub fn new_with_options ( options : & Options , output : W ) -> Self {
9090 Self {
@@ -183,10 +183,7 @@ where
183183 }
184184
185185 /// Process compressed data
186- fn read_data < R : BufRead > (
187- mut state : RunState < W > ,
188- mut input : & mut R ,
189- ) -> std:: io:: Result < RunState < W > > {
186+ fn read_data < R : BufRead > ( mut state : RunState < W > , mut input : & mut R ) -> io:: Result < RunState < W > > {
190187 // Construct our RangeDecoder from the previous range and code
191188 // values.
192189 let mut rangecoder = RangeDecoder :: from_parts ( & mut input, state. range , state. code ) ;
@@ -195,7 +192,7 @@ where
195192 state
196193 . decoder
197194 . process_stream ( & mut rangecoder)
198- . map_err ( |e| -> std :: io:: Error { e. into ( ) } ) ?;
195+ . map_err ( |e| -> io:: Error { e. into ( ) } ) ?;
199196
200197 Ok ( RunState {
201198 decoder : state. decoder ,
@@ -222,7 +219,7 @@ impl<W> Write for Stream<W>
222219where
223220 W : Write ,
224221{
225- fn write ( & mut self , data : & [ u8 ] ) -> std :: io:: Result < usize > {
222+ fn write ( & mut self , data : & [ u8 ] ) -> io:: Result < usize > {
226223 let mut input = Cursor :: new ( data) ;
227224
228225 if let Some ( state) = self . state . take ( ) {
@@ -237,8 +234,8 @@ where
237234 let bytes_read = if bytes_read < std:: u64:: MAX as usize {
238235 bytes_read as u64
239236 } else {
240- return Err ( std :: io:: Error :: new (
241- std :: io:: ErrorKind :: Other ,
237+ return Err ( io:: Error :: new (
238+ io:: ErrorKind :: Other ,
242239 "Failed to convert integer to u64." ,
243240 ) ) ;
244241 } ;
@@ -278,8 +275,8 @@ where
278275 let bytes_read = if bytes_read < std:: u64:: MAX as usize {
279276 bytes_read as u64
280277 } else {
281- return Err ( std :: io:: Error :: new (
282- std :: io:: ErrorKind :: Other ,
278+ return Err ( io:: Error :: new (
279+ io:: ErrorKind :: Other ,
283280 "Failed to convert integer to u64." ,
284281 ) ) ;
285282 } ;
@@ -298,7 +295,7 @@ where
298295 return Err ( match e {
299296 Error :: IoError ( e) | Error :: HeaderTooShort ( e) => e,
300297 Error :: LzmaError ( e) | Error :: XzError ( e) => {
301- std :: io:: Error :: new ( std :: io:: ErrorKind :: Other , e)
298+ io:: Error :: new ( io:: ErrorKind :: Other , e)
302299 }
303300 } ) ;
304301 }
@@ -327,7 +324,7 @@ where
327324 /// Flushes the output sink. The internal buffer isn't flushed to avoid
328325 /// corrupting the internal state. Instead, call `finish()` to finalize the
329326 /// stream and flush all remaining internal data.
330- fn flush ( & mut self ) -> std :: io:: Result < ( ) > {
327+ fn flush ( & mut self ) -> io:: Result < ( ) > {
331328 if let Some ( ref mut state) = self . state {
332329 match state {
333330 State :: Header ( _) => Ok ( ( ) ) ,
@@ -339,9 +336,9 @@ where
339336 }
340337}
341338
342- impl std :: convert :: Into < std :: io :: Error > for Error {
343- fn into ( self ) -> std :: io:: Error {
344- std :: io:: Error :: new ( std :: io:: ErrorKind :: Other , format ! ( "{:?}" , self ) )
339+ impl From < Error > for io :: Error {
340+ fn from ( error : Error ) -> io:: Error {
341+ io:: Error :: new ( io:: ErrorKind :: Other , format ! ( "{:?}" , error ) )
345342 }
346343}
347344
@@ -436,7 +433,7 @@ mod test {
436433 fn test_stream_chunked ( ) {
437434 let small_input = include_bytes ! ( "../../tests/files/small.txt" ) ;
438435
439- let mut reader = std :: io:: Cursor :: new ( & small_input[ ..] ) ;
436+ let mut reader = io:: Cursor :: new ( & small_input[ ..] ) ;
440437 let mut small_input_compressed = Vec :: new ( ) ;
441438 crate :: lzma_compress ( & mut reader, & mut small_input_compressed) . unwrap ( ) ;
442439
@@ -475,7 +472,7 @@ mod test {
475472 fn test_allow_incomplete ( ) {
476473 let input = include_bytes ! ( "../../tests/files/small.txt" ) ;
477474
478- let mut reader = std :: io:: Cursor :: new ( & input[ ..] ) ;
475+ let mut reader = io:: Cursor :: new ( & input[ ..] ) ;
479476 let mut compressed = Vec :: new ( ) ;
480477 crate :: lzma_compress ( & mut reader, & mut compressed) . unwrap ( ) ;
481478 let compressed = & compressed[ ..compressed. len ( ) / 2 ] ;
0 commit comments