Struct ajars_surf::surf::http::Response
[−]pub struct Response { /* private fields */ }
Expand description
An HTTP response.
Examples
use http_types::{Response, StatusCode};
let mut res = Response::new(StatusCode::Ok);
res.set_body("Hello, Nori!");
Implementations
impl Response
impl Response
pub fn new<S>(status: S) -> Response where
S: TryInto<StatusCode>,
<S as TryInto<StatusCode>>::Error: Debug,
pub fn new<S>(status: S) -> Response where
S: TryInto<StatusCode>,
<S as TryInto<StatusCode>>::Error: Debug,
Create a new response.
pub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the status
pub fn header_mut(
&mut self,
name: impl Into<HeaderName>
) -> Option<&mut HeaderValues>
pub fn header_mut(
&mut self,
name: impl Into<HeaderName>
) -> Option<&mut HeaderValues>
Get a mutable reference to a header.
pub fn header(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>
pub fn header(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>
Get an HTTP header.
pub fn remove_header(
&mut self,
name: impl Into<HeaderName>
) -> Option<HeaderValues>
pub fn remove_header(
&mut self,
name: impl Into<HeaderName>
) -> Option<HeaderValues>
Remove a header.
pub fn insert_header(
&mut self,
name: impl Into<HeaderName>,
values: impl ToHeaderValues
) -> Option<HeaderValues>
pub fn insert_header(
&mut self,
name: impl Into<HeaderName>,
values: impl ToHeaderValues
) -> Option<HeaderValues>
Set an HTTP header.
Examples
use http_types::{Method, Response, StatusCode, Url};
let mut req = Response::new(StatusCode::Ok);
req.insert_header("Content-Type", "text/plain");
pub fn append_header(
&mut self,
name: impl Into<HeaderName>,
values: impl ToHeaderValues
)
pub fn append_header(
&mut self,
name: impl Into<HeaderName>,
values: impl ToHeaderValues
)
Append a header to the headers.
Unlike insert
this function will not override the contents of a
header, but insert a header if there aren’t any. Or else append to
the existing list of headers.
Examples
use http_types::{Response, StatusCode};
let mut res = Response::new(StatusCode::Ok);
res.append_header("Content-Type", "text/plain");
pub fn set_body(&mut self, body: impl Into<Body>)
pub fn set_body(&mut self, body: impl Into<Body>)
Set the body reader.
Examples
use http_types::{Response, StatusCode};
let mut res = Response::new(StatusCode::Ok);
res.set_body("Hello, Nori!");
pub fn replace_body(&mut self, body: impl Into<Body>) -> Body
pub fn replace_body(&mut self, body: impl Into<Body>) -> Body
Replace the response body with a new body, returning the old body.
Examples
use http_types::{Body, Method, Response, StatusCode, Url};
let mut req = Response::new(StatusCode::Ok);
req.set_body("Hello, Nori!");
let mut body: Body = req.replace_body("Hello, Chashu");
let mut string = String::new();
body.read_to_string(&mut string).await?;
assert_eq!(&string, "Hello, Nori!");
pub fn swap_body(&mut self, body: &mut Body)
pub fn swap_body(&mut self, body: &mut Body)
Swaps the value of the body with another body, without deinitializing either one.
Examples
use http_types::{Body, Method, Response, StatusCode, Url};
let mut req = Response::new(StatusCode::Ok);
req.set_body("Hello, Nori!");
let mut body = "Hello, Chashu!".into();
req.swap_body(&mut body);
let mut string = String::new();
body.read_to_string(&mut string).await?;
assert_eq!(&string, "Hello, Nori!");
pub fn take_body(&mut self) -> Body
pub fn take_body(&mut self) -> Body
Take the response body, replacing it with an empty body.
Examples
use http_types::{Body, Method, Response, StatusCode, Url};
let mut req = Response::new(StatusCode::Ok);
req.set_body("Hello, Nori!");
let mut body: Body = req.take_body();
let mut string = String::new();
body.read_to_string(&mut string).await?;
assert_eq!(&string, "Hello, Nori!");
pub async fn body_string(&'_ mut self) -> Result<String, Error>
pub async fn body_string(&'_ mut self) -> Result<String, Error>
Read the body as a string.
This consumes the response. If you want to read the body without
consuming the response, consider using the take_body
method and
then calling Body::into_string
or using the Response’s AsyncRead
implementation to read the body.
Examples
use async_std::io::Cursor;
use http_types::{Body, Method, Response, StatusCode, Url};
let mut res = Response::new(StatusCode::Ok);
let cursor = Cursor::new("Hello Nori");
let body = Body::from_reader(cursor, None);
res.set_body(body);
assert_eq!(&res.body_string().await.unwrap(), "Hello Nori");
pub async fn body_bytes(&'_ mut self) -> Result<Vec<u8, Global>, Error>
pub async fn body_bytes(&'_ mut self) -> Result<Vec<u8, Global>, Error>
Read the body as bytes.
This consumes the Response
. If you want to read the body without
consuming the response, consider using the take_body
method and
then calling Body::into_bytes
or using the Response’s AsyncRead
implementation to read the body.
Examples
use http_types::{Body, Method, Response, StatusCode, Url};
let bytes = vec![1, 2, 3];
let mut res = Response::new(StatusCode::Ok);
res.set_body(Body::from_bytes(bytes));
let bytes = res.body_bytes().await?;
assert_eq!(bytes, vec![1, 2, 3]);
pub async fn body_json<T>(&'_ mut self) -> Result<T, Error> where
T: DeserializeOwned,
pub async fn body_json<T>(&'_ mut self) -> Result<T, Error> where
T: DeserializeOwned,
Read the body as JSON.
This consumes the response. If you want to read the body without
consuming the response, consider using the take_body
method and
then calling Body::into_json
or using the Response’s AsyncRead
implementation to read the body.
Examples
use http_types::convert::{Deserialize, Serialize};
use http_types::{Body, Method, Response, StatusCode, Url};
#[derive(Debug, Serialize, Deserialize)]
struct Cat {
name: String,
}
let cat = Cat {
name: String::from("chashu"),
};
let mut res = Response::new(StatusCode::Ok);
res.set_body(Body::from_json(&cat)?);
let cat: Cat = res.body_json().await?;
assert_eq!(&cat.name, "chashu");
pub async fn body_form<T>(&'_ mut self) -> Result<T, Error> where
T: DeserializeOwned,
pub async fn body_form<T>(&'_ mut self) -> Result<T, Error> where
T: DeserializeOwned,
Read the body as x-www-form-urlencoded
.
This consumes the request. If you want to read the body without
consuming the request, consider using the take_body
method and
then calling Body::into_json
or using the Response’s AsyncRead
implementation to read the body.
Examples
use http_types::convert::{Deserialize, Serialize};
use http_types::{Body, Method, Response, StatusCode, Url};
#[derive(Debug, Serialize, Deserialize)]
struct Cat {
name: String,
}
let cat = Cat {
name: String::from("chashu"),
};
let mut res = Response::new(StatusCode::Ok);
res.set_body(Body::from_form(&cat)?);
let cat: Cat = res.body_form().await?;
assert_eq!(&cat.name, "chashu");
pub fn set_content_type(&mut self, mime: Mime) -> Option<HeaderValues>
pub fn set_content_type(&mut self, mime: Mime) -> Option<HeaderValues>
Set the response MIME.
pub fn content_type(&self) -> Option<Mime>
pub fn content_type(&self) -> Option<Mime>
Get the current content type
pub fn len(&self) -> Option<usize>
pub fn len(&self) -> Option<usize>
Get the length of the body stream, if it has been set.
This value is set when passing a fixed-size object into as the body.
E.g. a string, or a buffer. Consumers of this API should check this
value to decide whether to use Chunked
encoding, or set the
response length.
pub fn is_empty(&self) -> Option<bool>
pub fn is_empty(&self) -> Option<bool>
Returns true
if the set length of the body stream is zero, false
otherwise.
pub fn version(&self) -> Option<Version>
pub fn version(&self) -> Option<Version>
Get the HTTP version, if one has been set.
Examples
use http_types::{Response, StatusCode, Version};
let mut res = Response::new(StatusCode::Ok);
assert_eq!(res.version(), None);
res.set_version(Some(Version::Http2_0));
assert_eq!(res.version(), Some(Version::Http2_0));
pub fn set_peer_addr(&mut self, peer_addr: Option<impl ToString>)
pub fn set_peer_addr(&mut self, peer_addr: Option<impl ToString>)
Sets a string representation of the peer address that this response was sent to. This might take the form of an ip/fqdn and port or a local socket address.
pub fn set_local_addr(&mut self, local_addr: Option<impl ToString>)
pub fn set_local_addr(&mut self, local_addr: Option<impl ToString>)
Sets a string representation of the local address that this response was sent on. This might take the form of an ip/fqdn and port, or a local socket address.
pub fn peer_addr(&self) -> Option<&str>
pub fn peer_addr(&self) -> Option<&str>
Get the peer socket address for the underlying transport, if appropriate
pub fn local_addr(&self) -> Option<&str>
pub fn local_addr(&self) -> Option<&str>
Get the local socket address for the underlying transport, if appropriate
pub fn set_version(&mut self, version: Option<Version>)
pub fn set_version(&mut self, version: Option<Version>)
Set the HTTP version.
Examples
use http_types::{Response, StatusCode, Version};
let mut res = Response::new(StatusCode::Ok);
res.set_version(Some(Version::Http2_0));
pub fn set_status(&mut self, status: StatusCode)
pub fn set_status(&mut self, status: StatusCode)
Set the status.
pub fn send_trailers(&mut self) -> Sender
pub fn send_trailers(&mut self) -> Sender
Sends trailers to the a receiver.
pub fn recv_trailers(&mut self) -> ReceiverⓘNotable traits for Receiverimpl Future for Receiver type Output = Option<Trailers>;
pub fn recv_trailers(&mut self) -> ReceiverⓘNotable traits for Receiverimpl Future for Receiver type Output = Option<Trailers>;
Receive trailers from a sender.
pub fn has_trailers(&self) -> bool
pub fn has_trailers(&self) -> bool
Returns true
if sending trailers is in progress.
pub fn send_upgrade(&mut self) -> Sender
pub fn send_upgrade(&mut self) -> Sender
Sends an upgrade connection to the a receiver.
pub async fn recv_upgrade(&'_ mut self) -> Receiver
pub async fn recv_upgrade(&'_ mut self) -> Receiver
Receive an upgraded connection from a sender.
pub fn has_upgrade(&self) -> bool
pub fn has_upgrade(&self) -> bool
Returns true
if a protocol upgrade is in progress.
pub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a HeaderName, &'a HeaderValues);
pub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a HeaderName, &'a HeaderValues);
An iterator visiting all header pairs in arbitrary order.
pub fn iter_mut(&mut self) -> IterMut<'_>ⓘNotable traits for IterMut<'a>impl<'a> Iterator for IterMut<'a> type Item = (&'a HeaderName, &'a mut HeaderValues);
pub fn iter_mut(&mut self) -> IterMut<'_>ⓘNotable traits for IterMut<'a>impl<'a> Iterator for IterMut<'a> type Item = (&'a HeaderName, &'a mut HeaderValues);
An iterator visiting all header pairs in arbitrary order, with mutable references to the values.
pub fn header_names(&self) -> Names<'_>ⓘNotable traits for Names<'a>impl<'a> Iterator for Names<'a> type Item = &'a HeaderName;
pub fn header_names(&self) -> Names<'_>ⓘNotable traits for Names<'a>impl<'a> Iterator for Names<'a> type Item = &'a HeaderName;
An iterator visiting all header names in arbitrary order.
pub fn header_values(&self) -> Values<'_>ⓘNotable traits for Values<'a>impl<'a> Iterator for Values<'a> type Item = &'a HeaderValue;
pub fn header_values(&self) -> Values<'_>ⓘNotable traits for Values<'a>impl<'a> Iterator for Values<'a> type Item = &'a HeaderValue;
An iterator visiting all header values in arbitrary order.
pub fn ext(&self) -> &Extensions
pub fn ext(&self) -> &Extensions
Returns a reference to the existing local.
pub fn ext_mut(&mut self) -> &mut Extensions
pub fn ext_mut(&mut self) -> &mut Extensions
Returns a mutuable reference to the existing local state.
Examples
use http_types::{Response, StatusCode, Version};
let mut res = Response::new(StatusCode::Ok);
res.ext_mut().insert("hello from the extension");
assert_eq!(res.ext().get(), Some(&"hello from the extension"));
Trait Implementations
impl AsyncBufRead for Response
impl AsyncBufRead for Response
impl AsyncRead for Response
impl AsyncRead for Response
impl From<StatusCode> for Response
impl From<StatusCode> for Response
fn from(s: StatusCode) -> Response
fn from(s: StatusCode) -> Response
Converts to this type from the input type.
impl<'_> Index<&'_ str> for Response
impl<'_> Index<&'_ str> for Response
fn index(&self, name: &str) -> &HeaderValues
fn index(&self, name: &str) -> &HeaderValues
Returns a reference to the value corresponding to the supplied name.
Panics
Panics if the name is not present in Response
.
type Output = HeaderValues
type Output = HeaderValues
The returned type after indexing.
impl Index<HeaderName> for Response
impl Index<HeaderName> for Response
fn index(&self, name: HeaderName) -> &HeaderValues
fn index(&self, name: HeaderName) -> &HeaderValues
Returns a reference to the value corresponding to the supplied name.
Panics
Panics if the name is not present in Response
.
type Output = HeaderValues
type Output = HeaderValues
The returned type after indexing.
impl IntoIterator for Response
impl IntoIterator for Response
fn into_iter(self) -> <Response as IntoIterator>::IntoIter
fn into_iter(self) -> <Response as IntoIterator>::IntoIter
Returns a iterator of references over the remaining items.
type Item = (HeaderName, HeaderValues)
type Item = (HeaderName, HeaderValues)
The type of the elements being iterated over.
impl<'a> IntoIterator for &'a Response
impl<'a> IntoIterator for &'a Response
type Item = (&'a HeaderName, &'a HeaderValues)
type Item = (&'a HeaderName, &'a HeaderValues)
The type of the elements being iterated over.
fn into_iter(self) -> <&'a Response as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a Response as IntoIterator>::IntoIter
Creates an iterator from a value. Read more
impl<'a> IntoIterator for &'a mut Response
impl<'a> IntoIterator for &'a mut Response
type Item = (&'a HeaderName, &'a mut HeaderValues)
type Item = (&'a HeaderName, &'a mut HeaderValues)
The type of the elements being iterated over.
fn into_iter(self) -> <&'a mut Response as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a mut Response as IntoIterator>::IntoIter
Creates an iterator from a value. Read more
impl<'__pin> Unpin for Response where
__Origin<'__pin>: Unpin,
Auto Trait Implementations
impl !RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl !UnwindSafe for Response
Blanket Implementations
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
fn fill_buf(&mut self) -> FillBuf<'_, Self> where
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self> where
Self: Unpin,
Returns the contents of the internal buffer, filling it with more data if empty. Read more
fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self> where
Self: Unpin,
fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self> where
Self: Unpin,
Reads all bytes and appends them into buf
until the delimiter byte
or EOF is found. Read more
fn read_line(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self> where
Self: Unpin,
fn read_line(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self> where
Self: Unpin,
Reads all bytes and appends them into buf
until a newline (the 0xA byte) or EOF is found. Read more
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
fn fill_buf(&mut self) -> FillBuf<'_, Self> where
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self> where
Self: Unpin,
Creates a future which will wait for a non-empty buffer to be available from this I/O object or EOF to be reached. Read more
fn consume_unpin(&mut self, amt: usize) where
Self: Unpin,
fn consume_unpin(&mut self, amt: usize) where
Self: Unpin,
fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntil<'a, Self> where
Self: Unpin,
fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntil<'a, Self> where
Self: Unpin,
Creates a future which will read all the bytes associated with this I/O
object into buf
until the delimiter byte
or EOF is reached.
This method is the async equivalent to BufRead::read_until
. Read more
fn read_line(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> where
Self: Unpin,
fn read_line(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> where
Self: Unpin,
Creates a future which will read all the bytes associated with this I/O
object into buf
until a newline (the 0xA byte) or EOF is reached,
This method is the async equivalent to BufRead::read_line
. Read more
fn lines(self) -> Lines<Self>
fn lines(self) -> Lines<Self>
Returns a stream over the lines of this reader.
This method is the async equivalent to BufRead::lines
. Read more
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
fn read(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> where
Self: Unpin,
fn read(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> where
Self: Unpin,
Reads some bytes from the byte stream. Read more
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
Like [read()
][AsyncReadExt::read()
], except it reads into a slice of buffers. Read more
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> where
Self: Unpin,
Reads the exact number of bytes required to fill buf
. Read more
fn take(self, limit: u64) -> Take<Self>
fn take(self, limit: u64) -> Take<Self>
Creates an adapter which will read at most limit
bytes from it. Read more
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
Creates an adaptor which will chain this stream with another. Read more
fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
Tries to read some bytes directly into the given buf
in asynchronous
manner, returning a future type. Read more
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
Creates a future which will read from the AsyncRead
into bufs
using vectored
IO operations. Read more
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
Creates a future which will read exactly enough bytes to fill buf
,
returning an error if end of file (EOF) is hit sooner. Read more
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
Creates a future which will read all the bytes from this AsyncRead
. Read more
fn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
fn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
Creates a future which will read all the bytes from this AsyncRead
. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
impl<T> BufReadExt for T where
T: AsyncBufRead + ?Sized,
impl<T> BufReadExt for T where
T: AsyncBufRead + ?Sized,
fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self> where
Self: Unpin,
fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self> where
Self: Unpin,
Reads all bytes into buf
until the delimiter byte
or EOF is reached. Read more
fn read_line(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self> where
Self: Unpin,
fn read_line(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self> where
Self: Unpin,
Reads all bytes and appends them into buf
until a newline (the 0xA byte) is
reached. Read more
impl<T> ReadExt for T where
T: AsyncRead + ?Sized,
impl<T> ReadExt for T where
T: AsyncRead + ?Sized,
fn read(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> where
Self: Unpin,
fn read(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> where
Self: Unpin,
Reads some bytes from the byte stream. Read more
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
Reads all bytes from the byte stream. Read more
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
Reads all bytes from the byte stream and appends them into a string. Read more
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> where
Self: Unpin,
Reads the exact number of bytes required to fill buf
. Read more
fn take(self, limit: u64) -> Take<Self>
fn take(self, limit: u64) -> Take<Self>
Creates an adaptor which will read at most limit
bytes from it. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more