diff --git a/gix-filter/Cargo.toml b/gix-filter/Cargo.toml index e955ab12e07..f7b3de607f6 100644 --- a/gix-filter/Cargo.toml +++ b/gix-filter/Cargo.toml @@ -22,7 +22,7 @@ gix-command = { version = "^0.5.0", path = "../gix-command" } gix-quote = { version = "^0.5.0", path = "../gix-quote" } gix-utils = { version = "^0.2.0", path = "../gix-utils" } gix-path = { version = "^0.10.15", path = "../gix-path" } -gix-packetline = { package = "gix-packetline-blocking", version = "^0.18.3", path = "../gix-packetline-blocking" } +gix-packetline-blocking = { version = "^0.18.3", path = "../gix-packetline-blocking" } gix-attributes = { version = "^0.25.0", path = "../gix-attributes" } encoding_rs = "0.8.32" diff --git a/gix-filter/src/driver/process/client.rs b/gix-filter/src/driver/process/client.rs index 57e59cc3e87..312b0600d4e 100644 --- a/gix-filter/src/driver/process/client.rs +++ b/gix-filter/src/driver/process/client.rs @@ -41,7 +41,7 @@ pub mod invoke { #[error("Failed to read or write to the process")] Io(#[from] std::io::Error), #[error(transparent)] - PacketlineDecode(#[from] gix_packetline::decode::Error), + PacketlineDecode(#[from] gix_packetline_blocking::decode::Error), } impl From for Error { @@ -65,17 +65,18 @@ impl Client { versions: &[usize], desired_capabilities: &[&str], ) -> Result { - let mut out = gix_packetline::Writer::new(process.stdin.take().expect("configured stdin when spawning")); + let mut out = + gix_packetline_blocking::Writer::new(process.stdin.take().expect("configured stdin when spawning")); out.write_all(format!("{welcome_prefix}-client").as_bytes())?; for version in versions { out.write_all(format!("version={version}").as_bytes())?; } - gix_packetline::encode::flush_to_write(out.inner_mut())?; + gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?; out.flush()?; - let mut input = gix_packetline::StreamingPeekableIter::new( + let mut input = gix_packetline_blocking::StreamingPeekableIter::new( process.stdout.take().expect("configured stdout when spawning"), - &[gix_packetline::PacketLineRef::Flush], + &[gix_packetline_blocking::PacketLineRef::Flush], false, /* packet tracing */ ); let mut read = input.as_read(); @@ -125,10 +126,10 @@ impl Client { for capability in desired_capabilities { out.write_all(format!("capability={capability}").as_bytes())?; } - gix_packetline::encode::flush_to_write(out.inner_mut())?; + gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?; out.flush()?; - read.reset_with(&[gix_packetline::PacketLineRef::Flush]); + read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]); let mut capabilities = HashSet::new(); loop { buf.clear(); @@ -167,7 +168,7 @@ impl Client { ) -> Result { self.send_command_and_meta(command, meta)?; std::io::copy(content, &mut self.input)?; - gix_packetline::encode::flush_to_write(self.input.inner_mut())?; + gix_packetline_blocking::encode::flush_to_write(self.input.inner_mut())?; self.input.flush()?; Ok(self.read_status()?) } @@ -189,7 +190,7 @@ impl Client { inspect_line(line.as_bstr()); } } - self.out.reset_with(&[gix_packetline::PacketLineRef::Flush]); + self.out.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]); let status = self.read_status()?; Ok(status) } @@ -197,7 +198,7 @@ impl Client { /// Return a `Read` implementation that reads the server process output until the next flush package, and validates /// the status. If the status indicates failure, the last read will also fail. pub fn as_read(&mut self) -> impl std::io::Read + '_ { - self.out.reset_with(&[gix_packetline::PacketLineRef::Flush]); + self.out.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]); ReadProcessOutputAndStatus { inner: self.out.as_read(), } @@ -225,7 +226,7 @@ impl Client { buf.push_str(&value); self.input.write_all(&buf)?; } - gix_packetline::encode::flush_to_write(self.input.inner_mut())?; + gix_packetline_blocking::encode::flush_to_write(self.input.inner_mut())?; Ok(()) } } @@ -248,7 +249,7 @@ fn read_status(read: &mut PacketlineReader<'_>) -> std::io::Result 0 && matches!(status, process::Status::Previous) { status = process::Status::Unset; } - read.reset_with(&[gix_packetline::PacketLineRef::Flush]); + read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]); Ok(status) } @@ -260,7 +261,7 @@ impl std::io::Read for ReadProcessOutputAndStatus<'_> { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let num_read = self.inner.read(buf)?; if num_read == 0 { - self.inner.reset_with(&[gix_packetline::PacketLineRef::Flush]); + self.inner.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]); let status = read_status(&mut self.inner)?; if status.is_success() { Ok(0) diff --git a/gix-filter/src/driver/process/mod.rs b/gix-filter/src/driver/process/mod.rs index b4e19c47a83..9377f2f9b10 100644 --- a/gix-filter/src/driver/process/mod.rs +++ b/gix-filter/src/driver/process/mod.rs @@ -12,9 +12,9 @@ pub struct Client { /// The negotiated version of the protocol. version: usize, /// A way to send packet-line encoded information to the process. - input: gix_packetline::Writer, + input: gix_packetline_blocking::Writer, /// A way to read information sent to us by the process. - out: gix_packetline::StreamingPeekableIter, + out: gix_packetline_blocking::StreamingPeekableIter, } /// A handle to facilitate typical server interactions that include the handshake and command-invocations. @@ -24,9 +24,9 @@ pub struct Server { /// The negotiated version of the protocol, it's the highest supported one. version: usize, /// A way to receive information from the client. - input: gix_packetline::StreamingPeekableIter>, + input: gix_packetline_blocking::StreamingPeekableIter>, /// A way to send information to the client. - out: gix_packetline::Writer>, + out: gix_packetline_blocking::Writer>, } /// The return status of an [invoked command][Client::invoke()]. @@ -109,5 +109,8 @@ pub mod client; /// pub mod server; -type PacketlineReader<'a, T = std::process::ChildStdout> = - gix_packetline::read::WithSidebands<'a, T, fn(bool, &[u8]) -> gix_packetline::read::ProgressAction>; +type PacketlineReader<'a, T = std::process::ChildStdout> = gix_packetline_blocking::read::WithSidebands< + 'a, + T, + fn(bool, &[u8]) -> gix_packetline_blocking::read::ProgressAction, +>; diff --git a/gix-filter/src/driver/process/server.rs b/gix-filter/src/driver/process/server.rs index 8afdebc3b63..971b5393bb2 100644 --- a/gix-filter/src/driver/process/server.rs +++ b/gix-filter/src/driver/process/server.rs @@ -26,7 +26,7 @@ pub mod next_request { #[error("{msg} '{actual}'")] Protocol { msg: String, actual: BString }, #[error(transparent)] - PacketlineDecode(#[from] gix_packetline::decode::Error), + PacketlineDecode(#[from] gix_packetline_blocking::decode::Error), } } @@ -63,9 +63,9 @@ impl Server { pick_version: &mut dyn FnMut(&[usize]) -> Option, available_capabilities: &[&str], ) -> Result { - let mut input = gix_packetline::StreamingPeekableIter::new( + let mut input = gix_packetline_blocking::StreamingPeekableIter::new( stdin.lock(), - &[gix_packetline::PacketLineRef::Flush], + &[gix_packetline_blocking::PacketLineRef::Flush], false, /* packet tracing */ ); let mut read = input.as_read(); @@ -104,11 +104,11 @@ impl Server { ); } let version = pick_version(&versions).ok_or(handshake::Error::VersionMismatch { actual: versions })?; - read.reset_with(&[gix_packetline::PacketLineRef::Flush]); - let mut out = gix_packetline::Writer::new(stdout.lock()); + read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]); + let mut out = gix_packetline_blocking::Writer::new(stdout.lock()); out.write_all(format!("{welcome_prefix}-server").as_bytes())?; out.write_all(format!("version={version}").as_bytes())?; - gix_packetline::encode::flush_to_write(out.inner_mut())?; + gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?; out.flush()?; let mut capabilities = HashSet::new(); @@ -132,7 +132,7 @@ impl Server { for cap in &capabilities { out.write_all(format!("capability={cap}").as_bytes())?; } - gix_packetline::encode::flush_to_write(out.inner_mut())?; + gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?; out.flush()?; drop(read); @@ -196,7 +196,7 @@ impl Server { } drop(read); - self.input.reset_with(&[gix_packetline::PacketLineRef::Flush]); + self.input.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]); Ok(Some(Request { parent: self, @@ -233,7 +233,7 @@ mod request { if let Some(message) = status.message() { out.write_all(format!("status={message}").as_bytes())?; } - gix_packetline::encode::flush_to_write(out.inner_mut())?; + gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?; out.flush() } } @@ -248,7 +248,7 @@ mod request { } struct WriteAndFlushOnDrop<'a> { - inner: &'a mut gix_packetline::Writer>, + inner: &'a mut gix_packetline_blocking::Writer>, } impl std::io::Write for WriteAndFlushOnDrop<'_> { @@ -263,7 +263,7 @@ mod request { impl Drop for WriteAndFlushOnDrop<'_> { fn drop(&mut self) { - gix_packetline::encode::flush_to_write(self.inner.inner_mut()).ok(); + gix_packetline_blocking::encode::flush_to_write(self.inner.inner_mut()).ok(); self.inner.flush().ok(); } } diff --git a/gix-packetline-blocking/Cargo.toml b/gix-packetline-blocking/Cargo.toml index b1febf34603..70fa873821b 100644 --- a/gix-packetline-blocking/Cargo.toml +++ b/gix-packetline-blocking/Cargo.toml @@ -24,9 +24,6 @@ blocking-io = [] ## DO NOT USE, instead use `gix-packetline` directly. async-io = [] -## DO NOT USE, instead use `gix-packetline` directly (and still don't specify `futures-lite`). -futures-lite = [] - #! ### Other ## Data structures implement `serde::Serialize` and `serde::Deserialize`. serde = ["dep:serde", "bstr/serde"]