Struct stdio::StdioReadGuard

source ·
pub struct StdioReadGuard<'a> { /* private fields */ }
Expand description

StdioReadGuard acts like MutexGuard, it locks the underlying ring buffer during its lifetime, and provides reading methods to the ring buffer. The lock will be automatically released on dropping of this structure.

Implementations§

source§

impl<'a> StdioReadGuard<'a>

source

pub fn try_read(&mut self, buf: &mut [u8]) -> Result<usize, Error>

Same as read(), but is non-blocking.

Returns Ok(0) when the underlying buffer is empty.

source

pub fn remaining_bytes(&self) -> usize

Returns the number of bytes still in the read buffer.

source§

impl<'a> StdioReadGuard<'a>

source

pub fn is_eof(&self) -> bool

Check if the EOF flag of the queue has been set.

Trait Implementations§

source§

impl<'a> Read for StdioReadGuard<'a>

source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>

Read from the ring buffer. Returns the number of bytes read.

Currently it is not possible to return an error, but one should not assume that because it is subject to change in the future.

Note that this method will block until at least one byte is available to be read. It will only return zero under one of two scenarios:

  1. The EOF flag has been set.
  2. The buffer specified was 0 bytes in length.
§

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
§

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
§

unsafe fn initializer(&self) -> Initializer

Determines if this Reader can work with buffers of uninitialized memory. Read more
§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Read the exact number of bytes required to fill buf. Read more
§

fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
§

fn bytes(self) -> Bytes<Self>where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
§

fn chain<R>(self, next: R) -> Chain<Self, R>where R: Read, Self: Sized,

Creates an adaptor which will chain this stream with another. Read more
§

fn take(self, limit: u64) -> Take<Self>where Self: Sized,

Creates an adaptor which will read at most limit bytes from it. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for StdioReadGuard<'a>

§

impl<'a> Send for StdioReadGuard<'a>

§

impl<'a> Sync for StdioReadGuard<'a>

§

impl<'a> Unpin for StdioReadGuard<'a>

§

impl<'a> !UnwindSafe for StdioReadGuard<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.