Struct bytecodec::io::WriteBuf [−][src]
pub struct WriteBuf<B> { /* fields omitted */ }
Write buffer.
Methods
impl<B: AsRef<[u8]> + AsMut<[u8]>> WriteBuf<B>
[src]
impl<B: AsRef<[u8]> + AsMut<[u8]>> WriteBuf<B>
pub fn new(inner: B) -> Self
[src]
pub fn new(inner: B) -> Self
Makes a new WriteBuf
instance.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of encoded bytes in the buffer.
pub fn room(&self) -> usize
[src]
pub fn room(&self) -> usize
Returns the free space of the buffer.
Invariant: self.len() + self.room() <= self.capacity()
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Returns the capacity of the buffer.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true
if the buffer is empty, otherwise false
.
pub fn is_full(&self) -> bool
[src]
pub fn is_full(&self) -> bool
Returns true
if the buffer is full, otherwise false
.
pub fn stream_state(&self) -> StreamState
[src]
pub fn stream_state(&self) -> StreamState
Returns the state of the stream that operated in the last flush()
call.
pub fn stream_state_mut(&mut self) -> &mut StreamState
[src]
pub fn stream_state_mut(&mut self) -> &mut StreamState
Returns a mutable reference to the StreamState
instance.
pub fn flush<W: Write>(&mut self, writer: W) -> Result<()>
[src]
pub fn flush<W: Write>(&mut self, writer: W) -> Result<()>
Writes the encoded bytes contained in this buffer to the given writer.
The written bytes will be removed from the buffer.
The flush process continues until one of the following condition is satisfied:
- The write buffer became empty
- A write operation returned a
WouldBlock
error - The output stream has reached EOS
ⓘImportant traits for &'a mut Rpub fn inner_ref(&self) -> &B
[src]
pub fn inner_ref(&self) -> &B
Returns a reference to the inner bytes of the buffer.
ⓘImportant traits for &'a mut Rpub fn inner_mut(&mut self) -> &mut B
[src]
pub fn inner_mut(&mut self) -> &mut B
Returns a mutable reference to the inner bytes of the buffer.
pub fn into_inner(self) -> B
[src]
pub fn into_inner(self) -> B
Takes ownership of ReadBuf
and returns the inner bytes of the buffer.
Trait Implementations
impl<B: Debug> Debug for WriteBuf<B>
[src]
impl<B: Debug> Debug for WriteBuf<B>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<B: AsRef<[u8]> + AsMut<[u8]>> Write for WriteBuf<B>
[src]
impl<B: AsRef<[u8]> + AsMut<[u8]>> Write for WriteBuf<B>
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
Writes a formatted string into this writer, returning any error encountered. Read more
ⓘImportant traits for &'a mut Rfn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Creates a "by reference" adaptor for this instance of Write
. Read more