pub struct BodyWithConfig<'a> { /* private fields */ }Expand description
Configuration of how to read the body.
Obtained via one of:
Implementations§
Source§impl<'a> BodyWithConfig<'a>
impl<'a> BodyWithConfig<'a>
Sourcepub fn limit(self, value: u64) -> Self
pub fn limit(self, value: u64) -> Self
Limit the response body.
Controls how many bytes we should read before throwing an error. This is used to ensure RAM isn’t exhausted by a server sending a very large response body.
The default limit is u64::MAX (unlimited).
Sourcepub fn lossy_utf8(self, value: bool) -> Self
pub fn lossy_utf8(self, value: bool) -> Self
Replace invalid utf-8 chars.
true means that broken utf-8 characters are replaced by a question mark ?
(not utf-8 replacement char). This happens after charset conversion regardless of
whether the charset feature is enabled or not.
The default is false.
Sourcepub fn reader(self) -> BodyReader<'a> ⓘ
pub fn reader(self) -> BodyReader<'a> ⓘ
Creates a reader.
The reader is either shared or owned, depending on with_config or into_with_config.
Consider:
// Creates an owned reader.
let reader = ureq::get("https://httpbin.org/get")
.call()?
.into_body()
// takes ownership of Body
.into_with_config()
.limit(10)
.reader();// Creates a shared reader.
let reader = ureq::get("https://httpbin.org/get")
.call()?
.body_mut()
// borrows Body
.with_config()
.limit(10)
.reader();Sourcepub fn read_to_string(self) -> Result<String, Error>
pub fn read_to_string(self) -> Result<String, Error>
Read into string.
Sourcepub fn read_json<T: DeserializeOwned>(self) -> Result<T, Error>
pub fn read_json<T: DeserializeOwned>(self) -> Result<T, Error>
Read JSON body.
Auto Trait Implementations§
impl<'a> !Freeze for BodyWithConfig<'a>
impl<'a> !RefUnwindSafe for BodyWithConfig<'a>
impl<'a> Send for BodyWithConfig<'a>
impl<'a> Sync for BodyWithConfig<'a>
impl<'a> Unpin for BodyWithConfig<'a>
impl<'a> !UnwindSafe for BodyWithConfig<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more