pub struct FileDownload {
pub content: Vec<u8>,
pub content_type: String,
pub filename: String,
pub size: u64,
}
Expand description
File download response
Fields§
§content: Vec<u8>
File content
content_type: String
Content type
filename: String
Original filename
size: u64
File size
Implementations§
Source§impl FileDownload
impl FileDownload
Sourcepub async fn save_to_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub async fn save_to_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Save content to a file
Sourcepub fn as_string(&self) -> Result<String, FromUtf8Error>
pub fn as_string(&self) -> Result<String, FromUtf8Error>
Get content as string (for text files)
Sourcepub fn as_json<T>(&self) -> Result<T, Error>where
T: for<'de> Deserialize<'de>,
pub fn as_json<T>(&self) -> Result<T, Error>where
T: for<'de> Deserialize<'de>,
Get content as JSON (for JSON files)
Trait Implementations§
Source§impl Clone for FileDownload
impl Clone for FileDownload
Source§fn clone(&self) -> FileDownload
fn clone(&self) -> FileDownload
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for FileDownload
impl RefUnwindSafe for FileDownload
impl Send for FileDownload
impl Sync for FileDownload
impl Unpin for FileDownload
impl UnwindSafe for FileDownload
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