pub struct ToFile { /* private fields */ }Expand description
Helper type to write a DeboaResponse to a file.
Implementations§
Source§impl ToFile
impl ToFile
Sourcepub async fn save<P, EV>(self, path: P, on_progress: Option<EV>) -> Result<()>
pub async fn save<P, EV>(self, path: P, on_progress: Option<EV>) -> Result<()>
Save the response body to a file asynchronously.
§Arguments
path- The path where the file will be savedon_progress- Optional callback function that receives the number of bytes written
§Returns
Result<()>- Ok if successful, Err with IoError if failed
§Examples
ⓘ
use deboa::{request::get, Deboa};
use deboa_extras::http::utils::file::IntoFile;
let mut client = Deboa::default();
let response = get("https://example.com").send_with(&mut client).await?;
response.into_file().save("output.txt", None).await?;Auto Trait Implementations§
impl !Freeze for ToFile
impl !RefUnwindSafe for ToFile
impl Send for ToFile
impl Sync for ToFile
impl Unpin for ToFile
impl !UnwindSafe for ToFile
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