Struct rmp_futures::encode::ArrayFuture
source · [−]pub struct ArrayFuture<W> { /* private fields */ }Implementations
sourceimpl<W: AsyncWrite + Unpin> ArrayFuture<W>
impl<W: AsyncWrite + Unpin> ArrayFuture<W>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
sourcepub fn end(self) -> W
pub fn end(self) -> W
Return the underlying writer from this ArrayFuture that has already
written all elements (len == 0).
#Panics
Panics if self.is_empty() is false. next() must have been called as
many times as the array length originally written before calling this to
destroy the array wrapper.
sourcepub fn next(self) -> MsgPackWriter<Self>
pub fn next(self) -> MsgPackWriter<Self>
Return a MsgPackWriter for the next array element
Use for encoding a fixed amount of nesting of arrays/maps that can be
modeled with straight-line code. For recursion or looping where the depth
is not known at compile time, see next_dyn().
#Panics
Panics if self.is_empty() is true. next() must be called no more times
than the array length originally written.
sourcepub fn next_dyn(
&mut self
) -> MsgPackWriter<&mut (dyn AsyncWrite + Send + Unpin)>where
W: Send,
pub fn next_dyn(
&mut self
) -> MsgPackWriter<&mut (dyn AsyncWrite + Send + Unpin)>where
W: Send,
Return a MsgPackWriter for the next array element
Borrows from the ArrayFuture and the returned MsgPackWriter is based on
a trait object. This is useful for recursion. It is not possible to
manipulate this ArrayFuture while the MsgPackWriter exists, but the
user must be careful to write to it before dropping it, or the output
will be malformed.
#Panics
Panics if self.is_empty() is true. next() must be called no more times
than the array length originally written.
sourcepub fn last(self) -> MsgPackWriter<W>
pub fn last(self) -> MsgPackWriter<W>
If there is one element left, return a MsgPackWriter for the last array
element.
This will yield the underlying writer when the element is written. This
avoids have to also call end() after writing this element.
#Panics
Panics if self.len() != 1. next() must have been called as many times
as the array length originally written - 1 before calling this to destroy
the array wrapper.
pub async fn write_value(self, a: &[Value]) -> IoResult<W>where
W: Send,
pub async fn write_value_ref(self, a: &[ValueRef<'_>]) -> IoResult<W>where
W: Send,
Trait Implementations
sourceimpl<W: AsyncWrite + Unpin> AsyncWrite for ArrayFuture<W>
impl<W: AsyncWrite + Unpin> AsyncWrite for ArrayFuture<W>
sourcefn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<IoResult<usize>>
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<IoResult<usize>>
Attempt to write bytes from buf into the object. Read more
sourcefn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<IoResult<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<IoResult<()>>
Attempt to flush the object, ensuring that any buffered data reach their destination. Read more
Auto Trait Implementations
impl<W> RefUnwindSafe for ArrayFuture<W>where
W: RefUnwindSafe,
impl<W> Send for ArrayFuture<W>where
W: Send,
impl<W> Sync for ArrayFuture<W>where
W: Sync,
impl<W> Unpin for ArrayFuture<W>where
W: Unpin,
impl<W> UnwindSafe for ArrayFuture<W>where
W: UnwindSafe,
Blanket Implementations
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
Creates a future which will entirely flush this AsyncWrite. Read more
fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
Creates a future which will entirely close this AsyncWrite.
fn write(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
fn write(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
Creates a future which will write bytes from buf into the object. Read more
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self>where
Self: Unpin,
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self>where
Self: Unpin,
Creates a future which will write bytes from bufs into the object using vectored
IO operations. Read more
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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