diff options
Diffstat (limited to 'vendor/gix-packetline/src')
-rw-r--r-- | vendor/gix-packetline/src/lib.rs | 8 | ||||
-rw-r--r-- | vendor/gix-packetline/src/read/async_io.rs | 23 | ||||
-rw-r--r-- | vendor/gix-packetline/src/read/blocking_io.rs | 24 | ||||
-rw-r--r-- | vendor/gix-packetline/src/read/mod.rs | 4 | ||||
-rw-r--r-- | vendor/gix-packetline/src/read/sidebands/async_io.rs | 4 |
5 files changed, 55 insertions, 8 deletions
diff --git a/vendor/gix-packetline/src/lib.rs b/vendor/gix-packetline/src/lib.rs index c5dce1c66..95ecd59d2 100644 --- a/vendor/gix-packetline/src/lib.rs +++ b/vendor/gix-packetline/src/lib.rs @@ -3,10 +3,10 @@ //! For reading the packet line format use the [`StreamingPeekableIter`], and for writing the [`Writer`]. //! ## Feature Flags #![cfg_attr( - feature = "document-features", - cfg_attr(doc, doc = ::document_features::document_features!()) + all(doc, all(doc, feature = "document-features")), + doc = ::document_features::document_features!() )] -#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))] #![deny(missing_docs, rust_2018_idioms, unsafe_code)] const U16_HEX_BYTES: usize = 4; @@ -91,6 +91,8 @@ pub struct StreamingPeekableIter<T> { delimiters: &'static [PacketLineRef<'static>], is_done: bool, stopped_at: Option<PacketLineRef<'static>>, + #[cfg_attr(all(not(feature = "async-io"), not(feature = "blocking-io")), allow(dead_code))] + trace: bool, } /// Utilities to help decoding packet lines diff --git a/vendor/gix-packetline/src/read/async_io.rs b/vendor/gix-packetline/src/read/async_io.rs index 402c2434b..daa6bf4f8 100644 --- a/vendor/gix-packetline/src/read/async_io.rs +++ b/vendor/gix-packetline/src/read/async_io.rs @@ -44,12 +44,30 @@ where delimiters: &[PacketLineRef<'static>], fail_on_err_lines: bool, buf_resize: bool, + trace: bool, ) -> ExhaustiveOutcome<'a> { ( false, None, Some(match Self::read_line_inner(reader, buf).await { Ok(Ok(line)) => { + if trace { + match line { + #[allow(unused_variables)] + PacketLineRef::Data(d) => { + gix_trace::trace!("<< {}", d.as_bstr().trim().as_bstr()); + } + PacketLineRef::Flush => { + gix_trace::trace!("<< FLUSH"); + } + PacketLineRef::Delimiter => { + gix_trace::trace!("<< DELIM"); + } + PacketLineRef::ResponseEnd => { + gix_trace::trace!("<< RESPONSE_END"); + } + } + } if delimiters.contains(&line) { let stopped_at = delimiters.iter().find(|l| **l == line).copied(); buf.clear(); @@ -111,6 +129,7 @@ where self.delimiters, self.fail_on_err_lines, false, + self.trace, ) .await; self.is_done = is_done; @@ -119,7 +138,8 @@ where } } - /// Peek the next packet line without consuming it. + /// Peek the next packet line without consuming it. Returns `None` if a stop-packet or an error + /// was encountered. /// /// Multiple calls to peek will return the same packet line, if there is one. pub async fn peek_line(&mut self) -> Option<io::Result<Result<PacketLineRef<'_>, decode::Error>>> { @@ -134,6 +154,7 @@ where self.delimiters, self.fail_on_err_lines, true, + self.trace, ) .await; self.is_done = is_done; diff --git a/vendor/gix-packetline/src/read/blocking_io.rs b/vendor/gix-packetline/src/read/blocking_io.rs index 50c634c4c..3e74e47f1 100644 --- a/vendor/gix-packetline/src/read/blocking_io.rs +++ b/vendor/gix-packetline/src/read/blocking_io.rs @@ -38,12 +38,30 @@ where delimiters: &[PacketLineRef<'static>], fail_on_err_lines: bool, buf_resize: bool, + trace: bool, ) -> ExhaustiveOutcome<'a> { ( false, None, Some(match Self::read_line_inner(reader, buf) { Ok(Ok(line)) => { + if trace { + match line { + #[allow(unused_variables)] + PacketLineRef::Data(d) => { + gix_trace::trace!("<< {}", d.as_bstr().trim().as_bstr()); + } + PacketLineRef::Flush => { + gix_trace::trace!("<< FLUSH"); + } + PacketLineRef::Delimiter => { + gix_trace::trace!("<< DELIM"); + } + PacketLineRef::ResponseEnd => { + gix_trace::trace!("<< RESPONSE_END"); + } + } + } if delimiters.contains(&line) { let stopped_at = delimiters.iter().find(|l| **l == line).copied(); buf.clear(); @@ -66,6 +84,7 @@ where if buf_resize { buf.resize(len, 0); } + // TODO(borrowchk): remove additional decoding of internal buffer which is needed only to make it past borrowchk Ok(Ok(crate::decode(buf).expect("only valid data here"))) } Ok(Err(err)) => { @@ -105,6 +124,7 @@ where self.delimiters, self.fail_on_err_lines, false, + self.trace, ); self.is_done = is_done; self.stopped_at = stopped_at; @@ -112,7 +132,8 @@ where } } - /// Peek the next packet line without consuming it. + /// Peek the next packet line without consuming it. Returns `None` if a stop-packet or an error + /// was encountered. /// /// Multiple calls to peek will return the same packet line, if there is one. pub fn peek_line(&mut self) -> Option<io::Result<Result<PacketLineRef<'_>, decode::Error>>> { @@ -127,6 +148,7 @@ where self.delimiters, self.fail_on_err_lines, true, + self.trace, ); self.is_done = is_done; self.stopped_at = stopped_at; diff --git a/vendor/gix-packetline/src/read/mod.rs b/vendor/gix-packetline/src/read/mod.rs index 0fd30c892..c9d01c1ab 100644 --- a/vendor/gix-packetline/src/read/mod.rs +++ b/vendor/gix-packetline/src/read/mod.rs @@ -43,7 +43,8 @@ pub use error::Error; impl<T> StreamingPeekableIter<T> { /// Return a new instance from `read` which will stop decoding packet lines when receiving one of the given `delimiters`. - pub fn new(read: T, delimiters: &'static [PacketLineRef<'static>]) -> Self { + /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. + pub fn new(read: T, delimiters: &'static [PacketLineRef<'static>], trace: bool) -> Self { StreamingPeekableIter { read, #[cfg(any(feature = "blocking-io", feature = "async-io"))] @@ -53,6 +54,7 @@ impl<T> StreamingPeekableIter<T> { fail_on_err_lines: false, is_done: false, stopped_at: None, + trace, } } diff --git a/vendor/gix-packetline/src/read/sidebands/async_io.rs b/vendor/gix-packetline/src/read/sidebands/async_io.rs index 37f93bca9..55c7bce26 100644 --- a/vendor/gix-packetline/src/read/sidebands/async_io.rs +++ b/vendor/gix-packetline/src/read/sidebands/async_io.rs @@ -80,12 +80,12 @@ mod tests { /// We want to declare items containing pointers of `StreamingPeekableIter` `Send` as well, so it must be `Send` itself. #[test] fn streaming_peekable_iter_is_send() { - receiver(StreamingPeekableIter::new(Vec::<u8>::new(), &[])); + receiver(StreamingPeekableIter::new(Vec::<u8>::new(), &[], false)); } #[test] fn state_is_send() { - let mut s = StreamingPeekableIter::new(Vec::<u8>::new(), &[]); + let mut s = StreamingPeekableIter::new(Vec::<u8>::new(), &[], false); receiver(State::Idle { parent: Some(&mut s) }); } } |