pub struct WithSidebands<'a, T, F>where
T: Read,{ /* private fields */ }
blocking-io
and (crate features blocking-io
or async-io
) only.Expand description
An implementor of BufRead
yielding packet lines on each call to read_line()
.
It’s also possible to hide the underlying packet lines using the Read
implementation which is useful
if they represent binary data, like the one of a pack file.
Implementations§
Source§impl<'a, T> WithSidebands<'a, T, fn(_: bool, _: &[u8]) -> ProgressAction>where
T: Read,
impl<'a, T> WithSidebands<'a, T, fn(_: bool, _: &[u8]) -> ProgressAction>where
T: Read,
Sourcepub fn new(parent: &'a mut StreamingPeekableIter<T>) -> Self
pub fn new(parent: &'a mut StreamingPeekableIter<T>) -> Self
Create a new instance with the given provider as parent
.
Source§impl<'a, T, F> WithSidebands<'a, T, F>
impl<'a, T, F> WithSidebands<'a, T, F>
Sourcepub fn with_progress_handler(
parent: &'a mut StreamingPeekableIter<T>,
handle_progress: F,
) -> Self
pub fn with_progress_handler( parent: &'a mut StreamingPeekableIter<T>, handle_progress: F, ) -> Self
Create a new instance with the given parent
provider and the handle_progress
function.
Progress or error information will be passed to the given handle_progress(is_error, text)
function, with is_error: bool
being true in case the text
is to be interpreted as error.
Sourcepub fn without_progress_handler(
parent: &'a mut StreamingPeekableIter<T>,
) -> Self
pub fn without_progress_handler( parent: &'a mut StreamingPeekableIter<T>, ) -> Self
Create a new instance without a progress handler.
Sourcepub fn reset_with(&mut self, delimiters: &'static [PacketLineRef<'static>])
pub fn reset_with(&mut self, delimiters: &'static [PacketLineRef<'static>])
Forwards to the parent StreamingPeekableIter::reset_with()
Sourcepub fn stopped_at(&self) -> Option<PacketLineRef<'static>>
pub fn stopped_at(&self) -> Option<PacketLineRef<'static>>
Forwards to the parent StreamingPeekableIter::stopped_at()
Sourcepub fn set_progress_handler(&mut self, handle_progress: Option<F>)
pub fn set_progress_handler(&mut self, handle_progress: Option<F>)
Set or unset the progress handler.
Sourcepub fn peek_data_line(&mut self) -> Option<Result<Result<&[u8], Error>>>
pub fn peek_data_line(&mut self) -> Option<Result<Result<&[u8], Error>>>
Effectively forwards to the parent StreamingPeekableIter::peek_line()
, allowing to see what would be returned
next on a call to read_line()
.
§Warning
This skips all sideband handling and may return an unprocessed line with sidebands still contained in it.
Sourcepub fn read_data_line(
&mut self,
) -> Option<Result<Result<PacketLineRef<'_>, Error>>>
pub fn read_data_line( &mut self, ) -> Option<Result<Result<PacketLineRef<'_>, Error>>>
Read a whole packetline from the underlying reader, with empty lines indicating a stop packetline.
§Warning
This skips all sideband handling and may return an unprocessed line with sidebands still contained in it.
Sourcepub fn read_line_to_string(&mut self, buf: &mut String) -> Result<usize>
pub fn read_line_to_string(&mut self, buf: &mut String) -> Result<usize>
Like BufRead::read_line()
, but will only read one packetline at a time.
It will also be easier to call as sometimes it’s unclear which implementation we get on a type like this with plenty of generic parameters.
Trait Implementations§
Source§impl<T, F> BufRead for WithSidebands<'_, T, F>
impl<T, F> BufRead for WithSidebands<'_, T, F>
Source§fn fill_buf(&mut self) -> Result<&[u8]>
fn fill_buf(&mut self) -> Result<&[u8]>
Source§fn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
amt
bytes have been consumed from the buffer,
so they should no longer be returned in calls to read
. Read moreSource§fn has_data_left(&mut self) -> Result<bool, Error>
fn has_data_left(&mut self) -> Result<bool, Error>
buf_read_has_data_left
)Read
has any data left to be read. Read more1.83.0 · Source§fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
byte
or EOF is reached. Read more1.0.0 · Source§fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
0xA
byte) is reached, and append
them to the provided String
buffer. Read moreSource§impl<T, F> Drop for WithSidebands<'_, T, F>where
T: Read,
impl<T, F> Drop for WithSidebands<'_, T, F>where
T: Read,
Source§impl<T, F> Read for WithSidebands<'_, T, F>
impl<T, F> Read for WithSidebands<'_, T, F>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read more