Trait gix_transport::client::ReadlineBufRead
source · pub trait ReadlineBufRead: BufRead {
// Required methods
fn readline(&mut self) -> Option<Result<Result<PacketLineRef<'_>, Error>>>;
fn readline_str(&mut self, line: &mut String) -> Result<usize>;
}
Available on crate feature
blocking-client
only.Expand description
This trait exists to get a version of a gix_packetline::Provider
without type parameters,
but leave support for reading lines directly without forcing them through String
.
For the sake of usability, it also implements std::io::BufRead
making it trivial to
read pack files while keeping open the option to read individual lines with low overhead.
Required Methods§
sourcefn readline(&mut self) -> Option<Result<Result<PacketLineRef<'_>, Error>>>
fn readline(&mut self) -> Option<Result<Result<PacketLineRef<'_>, Error>>>
Read a packet line into the internal buffer and return it.
Returns None
if the end of iteration is reached because of one of the following:
- natural EOF
- ERR packet line encountered
- A
delimiter
packet line encountered
sourcefn readline_str(&mut self, line: &mut String) -> Result<usize>
fn readline_str(&mut self, line: &mut String) -> Result<usize>
Read a line similar to BufRead::read_line()
, but assure it doesn’t try to find newlines
which might concatenate multiple distinct packet lines.
Making this a trait method allows to handle differences between async and blocking.