From a2b44c81a993b08d7786ca8139796f586229c90b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 18 May 2021 10:55:32 +0800 Subject: [PATCH] [git-packetline] fix compile errors if no features are specified --- git-packetline/src/encode/mod.rs | 1 - git-packetline/src/read/mod.rs | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/git-packetline/src/encode/mod.rs b/git-packetline/src/encode/mod.rs index d6fd7e0e57f..c78f867eb2d 100644 --- a/git-packetline/src/encode/mod.rs +++ b/git-packetline/src/encode/mod.rs @@ -25,7 +25,6 @@ mod blocking_io; #[cfg(feature = "blocking-io")] pub use blocking_io::*; -#[cfg(any(feature = "async-io", feature = "blocking-io"))] pub(crate) fn u16_to_hex(value: u16) -> [u8; 4] { let mut buf = [0u8; 4]; hex::encode_to_slice((value as u16).to_be_bytes(), &mut buf).expect("two bytes to 4 hex chars never fails"); diff --git a/git-packetline/src/read/mod.rs b/git-packetline/src/read/mod.rs index 93a9369a99f..ab47f5b0929 100644 --- a/git-packetline/src/read/mod.rs +++ b/git-packetline/src/read/mod.rs @@ -1,4 +1,6 @@ -use crate::{PacketLine, MAX_LINE_LEN, U16_HEX_BYTES}; +#[cfg(any(feature = "blocking-io", feature = "async-io"))] +use crate::MAX_LINE_LEN; +use crate::{PacketLine, U16_HEX_BYTES}; /// Read pack lines one after another, without consuming more than needed from the underlying /// [`Read`][std::io::Read]. [`Flush`][PacketLine::Flush] lines cause the reader to stop producing lines forever, @@ -8,6 +10,7 @@ use crate::{PacketLine, MAX_LINE_LEN, U16_HEX_BYTES}; pub struct StreamingPeekableIter { read: T, peek_buf: Vec, + #[cfg(any(feature = "blocking-io", feature = "async-io"))] buf: Vec, fail_on_err_lines: bool, delimiters: &'static [PacketLine<'static>], @@ -20,6 +23,7 @@ impl StreamingPeekableIter { pub fn new(read: T, delimiters: &'static [PacketLine<'static>]) -> Self { StreamingPeekableIter { read, + #[cfg(any(feature = "blocking-io", feature = "async-io"))] buf: vec![0; MAX_LINE_LEN], peek_buf: Vec::new(), delimiters, @@ -90,4 +94,5 @@ mod blocking_io; mod async_io; mod sidebands; +#[cfg(any(feature = "blocking-io", feature = "async-io"))] pub use sidebands::WithSidebands;