11use std:: { collections:: HashSet , io:: Write , str:: FromStr } ;
22
33use bstr:: { BStr , BString , ByteVec } ;
4+ use gix_packetline:: blocking_io:: { encode, StreamingPeekableIter , Writer } ;
45
56use crate :: driver:: {
67 process,
@@ -41,7 +42,7 @@ pub mod invoke {
4142 #[ error( "Failed to read or write to the process" ) ]
4243 Io ( #[ from] std:: io:: Error ) ,
4344 #[ error( transparent) ]
44- PacketlineDecode ( #[ from] gix_packetline_blocking :: decode:: Error ) ,
45+ PacketlineDecode ( #[ from] gix_packetline :: decode:: Error ) ,
4546 }
4647
4748 impl From < super :: Error > for Error {
@@ -65,18 +66,17 @@ impl Client {
6566 versions : & [ usize ] ,
6667 desired_capabilities : & [ & str ] ,
6768 ) -> Result < Self , handshake:: Error > {
68- let mut out =
69- gix_packetline_blocking:: Writer :: new ( process. stdin . take ( ) . expect ( "configured stdin when spawning" ) ) ;
69+ let mut out = Writer :: new ( process. stdin . take ( ) . expect ( "configured stdin when spawning" ) ) ;
7070 out. write_all ( format ! ( "{welcome_prefix}-client" ) . as_bytes ( ) ) ?;
7171 for version in versions {
7272 out. write_all ( format ! ( "version={version}" ) . as_bytes ( ) ) ?;
7373 }
74- gix_packetline_blocking :: encode:: flush_to_write ( out. inner_mut ( ) ) ?;
74+ encode:: flush_to_write ( out. inner_mut ( ) ) ?;
7575 out. flush ( ) ?;
7676
77- let mut input = gix_packetline_blocking :: StreamingPeekableIter :: new (
77+ let mut input = StreamingPeekableIter :: new (
7878 process. stdout . take ( ) . expect ( "configured stdout when spawning" ) ,
79- & [ gix_packetline_blocking :: PacketLineRef :: Flush ] ,
79+ & [ gix_packetline :: PacketLineRef :: Flush ] ,
8080 false , /* packet tracing */
8181 ) ;
8282 let mut read = input. as_read ( ) ;
@@ -126,10 +126,10 @@ impl Client {
126126 for capability in desired_capabilities {
127127 out. write_all ( format ! ( "capability={capability}" ) . as_bytes ( ) ) ?;
128128 }
129- gix_packetline_blocking :: encode:: flush_to_write ( out. inner_mut ( ) ) ?;
129+ encode:: flush_to_write ( out. inner_mut ( ) ) ?;
130130 out. flush ( ) ?;
131131
132- read. reset_with ( & [ gix_packetline_blocking :: PacketLineRef :: Flush ] ) ;
132+ read. reset_with ( & [ gix_packetline :: PacketLineRef :: Flush ] ) ;
133133 let mut capabilities = HashSet :: new ( ) ;
134134 loop {
135135 buf. clear ( ) ;
@@ -168,7 +168,7 @@ impl Client {
168168 ) -> Result < process:: Status , invoke:: Error > {
169169 self . send_command_and_meta ( command, meta) ?;
170170 std:: io:: copy ( content, & mut self . input ) ?;
171- gix_packetline_blocking :: encode:: flush_to_write ( self . input . inner_mut ( ) ) ?;
171+ encode:: flush_to_write ( self . input . inner_mut ( ) ) ?;
172172 self . input . flush ( ) ?;
173173 Ok ( self . read_status ( ) ?)
174174 }
@@ -190,15 +190,15 @@ impl Client {
190190 inspect_line ( line. as_bstr ( ) ) ;
191191 }
192192 }
193- self . out . reset_with ( & [ gix_packetline_blocking :: PacketLineRef :: Flush ] ) ;
193+ self . out . reset_with ( & [ gix_packetline :: PacketLineRef :: Flush ] ) ;
194194 let status = self . read_status ( ) ?;
195195 Ok ( status)
196196 }
197197
198198 /// Return a `Read` implementation that reads the server process output until the next flush package, and validates
199199 /// the status. If the status indicates failure, the last read will also fail.
200200 pub fn as_read ( & mut self ) -> impl std:: io:: Read + ' _ {
201- self . out . reset_with ( & [ gix_packetline_blocking :: PacketLineRef :: Flush ] ) ;
201+ self . out . reset_with ( & [ gix_packetline :: PacketLineRef :: Flush ] ) ;
202202 ReadProcessOutputAndStatus {
203203 inner : self . out . as_read ( ) ,
204204 }
@@ -226,7 +226,7 @@ impl Client {
226226 buf. push_str ( & value) ;
227227 self . input . write_all ( & buf) ?;
228228 }
229- gix_packetline_blocking :: encode:: flush_to_write ( self . input . inner_mut ( ) ) ?;
229+ encode:: flush_to_write ( self . input . inner_mut ( ) ) ?;
230230 Ok ( ( ) )
231231 }
232232}
@@ -249,7 +249,7 @@ fn read_status(read: &mut PacketlineReader<'_>) -> std::io::Result<process::Stat
249249 if count > 0 && matches ! ( status, process:: Status :: Previous ) {
250250 status = process:: Status :: Unset ;
251251 }
252- read. reset_with ( & [ gix_packetline_blocking :: PacketLineRef :: Flush ] ) ;
252+ read. reset_with ( & [ gix_packetline :: PacketLineRef :: Flush ] ) ;
253253 Ok ( status)
254254}
255255
@@ -261,7 +261,7 @@ impl std::io::Read for ReadProcessOutputAndStatus<'_> {
261261 fn read ( & mut self , buf : & mut [ u8 ] ) -> std:: io:: Result < usize > {
262262 let num_read = self . inner . read ( buf) ?;
263263 if num_read == 0 {
264- self . inner . reset_with ( & [ gix_packetline_blocking :: PacketLineRef :: Flush ] ) ;
264+ self . inner . reset_with ( & [ gix_packetline :: PacketLineRef :: Flush ] ) ;
265265 let status = read_status ( & mut self . inner ) ?;
266266 if status. is_success ( ) {
267267 Ok ( 0 )
0 commit comments