SerialLines

Struct SerialLines 

Source
pub struct SerialLines<ReaderTy> { /* private fields */ }
Expand description

Reads serial lines from an AsyncBufRead.

This tries to act a lot like the structure returned from .lines() on a normal async buf reader. Except instead of splitting on \n, we use \r.

Implementations§

Source§

impl<ReaderTy> SerialLines<ReaderTy>
where ReaderTy: AsyncBufRead + Unpin,

Source

pub async fn next_line(&mut self) -> IoResult<Option<String>>

Grab the next line from the serial line reader.

§Errors

If we get an IoError back from the underlying reader we’re reading from.

Source§

impl<ReaderTy> SerialLines<ReaderTy>
where ReaderTy: AsyncBufRead,

Source

pub fn new(reader: ReaderTy) -> Self

Create a new Serial Lines reader.

Source

pub const fn get_ref(&self) -> &ReaderTy

Get a constant reference to the current reader type.

Source

pub const fn get_mut(&mut self) -> &mut ReaderTy

Get a mutable reference to the current reader type.

Source

pub fn poll_next_line( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<IoResult<Option<String>>>

Polls for the next line in the stream.

This method returns:

  • Poll::Pending if the next line is not yet available.
  • Poll::Ready(Ok(Some(line))) if the next line is available.
  • Poll::Ready(Ok(None)) if there are no more lines in this stream.
  • Poll::Ready(Err(err)) if an IO error occurred while reading the next line.

When the method returns Poll::Pending, the Waker in the provided Context is scheduled to receive a wakeup when more bytes become available on the underlying IO resource. Note that on multiple calls to poll_next_line, only the Waker from the Context passed to the most recent call is scheduled to receive a wakeup.

Trait Implementations§

Source§

impl<ReaderTy: Debug> Debug for SerialLines<ReaderTy>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'__pin, ReaderTy> Unpin for SerialLines<ReaderTy>
where PinnedFieldsOf<__Origin<'__pin, ReaderTy>>: Unpin,

Auto Trait Implementations§

§

impl<ReaderTy> Freeze for SerialLines<ReaderTy>
where ReaderTy: Freeze,

§

impl<ReaderTy> RefUnwindSafe for SerialLines<ReaderTy>
where ReaderTy: RefUnwindSafe,

§

impl<ReaderTy> Send for SerialLines<ReaderTy>
where ReaderTy: Send,

§

impl<ReaderTy> Sync for SerialLines<ReaderTy>
where ReaderTy: Sync,

§

impl<ReaderTy> UnwindSafe for SerialLines<ReaderTy>
where ReaderTy: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more