pub struct RawCircle { /* private fields */ }Expand description
A thread-safe version of CharCircle.
The API of this buffer is almost identical to CharCircle except that it
uses external mutability, and it does not provide a means to consume its
characters from an external iterator.
Implementations§
Source§impl RawCircle
impl RawCircle
Sourcepub fn new(s: String) -> RawCircle ⓘ
pub fn new(s: String) -> RawCircle ⓘ
Construct a new RawCircle using a string as the initial buffer.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
The number of bytes the buffer can hold before reallocating.
This refers to the length of the backing vector. That vector may have additional capacity allocated to it that is not reported by this method.
Sourcepub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
pub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Read bytes from this circle into a buffer.
This method will only ever read complete UTF-8 characters. It returns the number of bytes read; it never returns an error.
This is the implementation of std::io::Read for RawCircle.
Sourcepub fn read_str<'a>(&mut self, buf: &'a mut [u8]) -> &'a str
pub fn read_str<'a>(&mut self, buf: &'a mut [u8]) -> &'a str
Read bytes from this circle into a buffer.
This method is equivalent to RawCircle::read except the return value
is the buffer cast to a &str.
Sourcepub fn write_char(&mut self, ch: char)
pub fn write_char(&mut self, ch: char)
Write a character into the buffer.
Sourcepub fn write(&mut self, buf: &[u8]) -> Result<usize>
pub fn write(&mut self, buf: &[u8]) -> Result<usize>
Read bytes from a string into this buffer;
This method will only ever write complete UTF-8 characters. It returns the number of bytes written. This method returns an error if the input is not valid UTF-8.
This is the implementation of std::io::Write for RawCircle.
Sourcepub fn write_str(&mut self, buf: &str) -> usize
pub fn write_str(&mut self, buf: &str) -> usize
Read bytes from a string into this buffer;
This method is equivalent to RawCircle::write except that it cannot return
an error because the input is valid UTF-8.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Unpack this circular buffer into a string.
Trait Implementations§
Source§impl Read for RawCircle
impl Read for RawCircle
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 moreSource§impl Write for RawCircle
impl Write for RawCircle
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)