Struct holochain::prelude::kitsune_p2p::dependencies::kitsune_p2p_types::dependencies::futures::io::Take
pub struct Take<R> { /* private fields */ }
Expand description
Reader for the take
method.
Implementations
impl<R> Take<R>where
R: AsyncRead,
impl<R> Take<R>where
R: AsyncRead,
pub fn limit(&self) -> u64
pub fn limit(&self) -> u64
Returns the remaining number of bytes that can be read before this instance will return EOF.
Note
This instance may reach EOF
after reading fewer bytes than indicated by
this method if the underlying AsyncRead
instance reaches EOF.
Examples
use futures::io::{AsyncReadExt, Cursor};
let reader = Cursor::new(&b"12345678"[..]);
let mut buffer = [0; 2];
let mut take = reader.take(4);
let n = take.read(&mut buffer).await?;
assert_eq!(take.limit(), 2);
pub fn set_limit(&mut self, limit: u64)
pub fn set_limit(&mut self, limit: u64)
Sets the number of bytes that can be read before this instance will
return EOF. This is the same as constructing a new Take
instance, so
the amount of bytes read and the previous limit value donโt matter when
calling this method.
Examples
use futures::io::{AsyncReadExt, Cursor};
let reader = Cursor::new(&b"12345678"[..]);
let mut buffer = [0; 4];
let mut take = reader.take(4);
let n = take.read(&mut buffer).await?;
assert_eq!(n, 4);
assert_eq!(take.limit(), 0);
take.set_limit(10);
let n = take.read(&mut buffer).await?;
assert_eq!(n, 4);
pub fn get_ref(&self) -> &R
pub fn get_ref(&self) -> &R
Acquires a reference to the underlying sink or stream that this combinator is pulling from.
pub fn get_mut(&mut self) -> &mut R
pub fn get_mut(&mut self) -> &mut R
Acquires a mutable reference to the underlying sink or stream that this combinator is pulling from.
Note that care must be taken to avoid tampering with the state of the sink or stream which may otherwise confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Take<R>>) -> Pin<&mut R>
pub fn get_pin_mut(self: Pin<&mut Take<R>>) -> Pin<&mut R>
Acquires a pinned mutable reference to the underlying sink or stream that this combinator is pulling from.
Note that care must be taken to avoid tampering with the state of the sink or stream which may otherwise confuse this combinator.
pub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consumes this combinator, returning the underlying sink or stream.
Note that this may discard intermediate state of this combinator, so care should be taken to avoid losing resources when this is called.
Trait Implementations
impl<R> AsyncBufRead for Take<R>where
R: AsyncBufRead,
impl<R> AsyncBufRead for Take<R>where
R: AsyncBufRead,
impl<R> AsyncRead for Take<R>where
R: AsyncRead,
impl<R> AsyncRead for Take<R>where
R: AsyncRead,
impl<'__pin, R> Unpin for Take<R>where
__Origin<'__pin, R>: Unpin,
Auto Trait Implementations
impl<R> RefUnwindSafe for Take<R>where
R: RefUnwindSafe,
impl<R> Send for Take<R>where
R: Send,
impl<R> Sync for Take<R>where
R: Sync,
impl<R> UnwindSafe for Take<R>where
R: UnwindSafe,
Blanket Implementations
impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
fn fill_buf(&mut self) -> FillBuf<'_, Self> โwhere
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self> โwhere
Self: Unpin,
fn consume_unpin(&mut self, amt: usize)where
Self: Unpin,
fn consume_unpin(&mut self, amt: usize)where
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntil<'a, Self> โwhere
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntil<'a, Self> โwhere
Self: Unpin,
buf
until the delimiter byte
or EOF is reached.
This method is the async equivalent to BufRead::read_until
. Read morefn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> โwhere
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> โwhere
Self: Unpin,
buf
until a newline (the 0xA byte) or EOF is reached,
This method is the async equivalent to BufRead::read_line
. Read morefn lines(self) -> Lines<Self>where
Self: Sized,
fn lines(self) -> Lines<Self>where
Self: Sized,
BufRead::lines
. Read moreimpl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
fn fill_buf(&mut self) -> FillBuf<'_, Self> โwhere
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self> โwhere
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self> โwhere
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self> โwhere
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self> โwhere
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self> โwhere
Self: Unpin,
buf
until a newline (the 0xA byte) or EOF is found. Read moreimpl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> โwhere
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> โwhere
Self: Unpin,
buf
in asynchronous
manner, returning a future type. Read morefn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> โwhere
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> โwhere
Self: Unpin,
AsyncRead
into bufs
using vectored
IO operations. Read morefn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> โwhere
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> โwhere
Self: Unpin,
buf
,
returning an error if end of file (EOF) is hit sooner. Read morefn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> โwhere
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> โwhere
Self: Unpin,
AsyncRead
. Read morefn read_to_string<'a>(
&'a mut self,
buf: &'a mut String
) -> ReadToString<'a, Self> โwhere
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String
) -> ReadToString<'a, Self> โwhere
Self: Unpin,
AsyncRead
. Read moreimpl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> โwhere
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> โwhere
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> โwhere
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> โwhere
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> โwhere
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> โwhere
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> โwhere
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> โwhere
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> โwhere
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> โwhere
Self: Unpin,
buf
. Read morefn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
limit
bytes from it. Read moresourceimpl<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
impl<T> BufReadExt for Twhere
T: AsyncBufRead + ?Sized,
impl<T> BufReadExt for Twhere
T: AsyncBufRead + ?Sized,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self>where
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self>where
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>where
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>where
Self: Unpin,
buf
until a newline (the 0xA byte) is
reached. Read moreimpl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
impl<T> FutureExt for T
impl<T> FutureExt for T
fn with_context(self, otel_cx: Context) -> WithContext<Self> โ
fn with_context(self, otel_cx: Context) -> WithContext<Self> โ
fn with_current_context(self) -> WithContext<Self> โ
fn with_current_context(self) -> WithContext<Self> โ
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
sourcefn in_current_span(self) -> Instrumented<Self> โ
fn in_current_span(self) -> Instrumented<Self> โ
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
sourcefn in_current_span(self) -> Instrumented<Self> โ
fn in_current_span(self) -> Instrumented<Self> โ
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> ReadExt for Twhere
T: AsyncRead + ?Sized,
impl<T> ReadExt for Twhere
T: AsyncRead + ?Sized,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
buf
. Read morefn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
limit
bytes from it. Read morefn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moreimpl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.