Struct git_packetline::read::WithSidebands
source · [−]pub struct WithSidebands<'a, T, F> where
T: Read, { /* private fields */ }
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
sourceimpl<'a, T> WithSidebands<'a, T, fn(_: bool, _: &[u8])> where
T: Read,
impl<'a, T> WithSidebands<'a, T, fn(_: bool, _: &[u8])> 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
.
sourceimpl<'a, T, F> WithSidebands<'a, T, F> where
T: Read,
F: FnMut(bool, &[u8]),
impl<'a, T, F> WithSidebands<'a, T, F> where
T: Read,
F: FnMut(bool, &[u8]),
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()
.
Trait Implementations
sourceimpl<'a, T, F> BufRead for WithSidebands<'a, T, F> where
T: Read,
F: FnMut(bool, &[u8]),
impl<'a, T, F> BufRead for WithSidebands<'a, T, F> where
T: Read,
F: FnMut(bool, &[u8]),
sourcefn fill_buf(&mut self) -> Result<&[u8]>
fn fill_buf(&mut self) -> Result<&[u8]>
Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
sourcefn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
Tells this buffer that amt
bytes have been consumed from the buffer,
so they should no longer be returned in calls to read
. Read more
sourcefn read_line(&mut self, buf: &mut String) -> Result<usize>
fn read_line(&mut self, buf: &mut String) -> Result<usize>
Read all bytes until a newline (the 0xA
byte) is reached, and append
them to the provided buffer. You do not need to clear the buffer before
appending. Read more
sourcefn has_data_left(&mut self) -> Result<bool, Error>
fn has_data_left(&mut self) -> Result<bool, Error>
buf_read_has_data_left
)Check if the underlying Read
has any data left to be read. Read more
1.0.0 · sourcefn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
Read all bytes into buf
until the delimiter byte
or EOF is reached. Read more
sourceimpl<'a, T, F> Drop for WithSidebands<'a, T, F> where
T: Read,
impl<'a, T, F> Drop for WithSidebands<'a, T, F> where
T: Read,
sourceimpl<'a, T, F> Read for WithSidebands<'a, T, F> where
T: Read,
F: FnMut(bool, &[u8]),
impl<'a, T, F> Read for WithSidebands<'a, T, F> where
T: Read,
F: FnMut(bool, &[u8]),
sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
1.36.0 · sourcefn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like read
, except that it reads into a slice of buffers. Read more
sourcefn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
1.0.0 · sourcefn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into buf
. Read more
1.0.0 · sourcefn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to buf
. Read more
1.6.0 · sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill buf
. Read more
sourcefn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Pull some bytes from this source into the specified buffer. Read more
sourcefn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Read the exact number of bytes required to fill buf
. Read more
1.0.0 · sourcefn by_ref(&mut self) -> &mut Self
fn by_ref(&mut self) -> &mut Self
Creates a “by reference” adaptor for this instance of Read
. Read more
Auto Trait Implementations
impl<'a, T, F> RefUnwindSafe for WithSidebands<'a, T, F> where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, F> Send for WithSidebands<'a, T, F> where
F: Send,
T: Send,
impl<'a, T, F> Sync for WithSidebands<'a, T, F> where
F: Sync,
T: Sync,
impl<'a, T, F> Unpin for WithSidebands<'a, T, F> where
F: Unpin,
impl<'a, T, F> !UnwindSafe for WithSidebands<'a, T, F>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<B> BufReadExt for B where
B: BufRead,
impl<B> BufReadExt for B where
B: BufRead,
sourcefn byte_lines(self) -> ByteLines<Self>
fn byte_lines(self) -> ByteLines<Self>
Returns an iterator over the lines of this reader, where each line is represented as a byte string. Read more
sourcefn byte_records(self, terminator: u8) -> ByteRecords<Self>
fn byte_records(self, terminator: u8) -> ByteRecords<Self>
Returns an iterator over byte-terminated records of this reader, where each record is represented as a byte string. Read more
sourcefn for_byte_line<F>(self, for_each_line: F) -> Result<(), Error> where
F: FnMut(&[u8]) -> Result<bool, Error>,
fn for_byte_line<F>(self, for_each_line: F) -> Result<(), Error> where
F: FnMut(&[u8]) -> Result<bool, Error>,
Executes the given closure on each line in the underlying reader. Read more
sourcefn for_byte_record<F>(
self,
terminator: u8,
for_each_record: F
) -> Result<(), Error> where
F: FnMut(&[u8]) -> Result<bool, Error>,
fn for_byte_record<F>(
self,
terminator: u8,
for_each_record: F
) -> Result<(), Error> where
F: FnMut(&[u8]) -> Result<bool, Error>,
Executes the given closure on each byte-terminated record in the underlying reader. Read more