pub struct UploadFile {
pub path: Option<PathBuf>,
pub name: String,
pub size: Option<u64>,
pub mime_hint: Option<String>,
}Expand description
Metadata describing one file offered to an upload control.
The value does not grant filesystem access and does not read the file.
§Examples
use ailloli_ui_core::UploadFile;
let file = UploadFile::named("report.pdf");
assert_eq!(file.name, "report.pdf");
assert_eq!(file.size, None);Fields§
§path: Option<PathBuf>Local path when the producer is allowed to expose one; None otherwise.
name: StringDisplay name used for extension matching; it may be empty.
size: Option<u64>File size in bytes when known; None means unavailable, not zero bytes.
mime_hint: Option<String>Unverified MIME type hint when known; matching is ASCII case-insensitive.
Implementations§
Source§impl UploadFile
impl UploadFile
Sourcepub fn named(name: impl Into<String>) -> Self
pub fn named(name: impl Into<String>) -> Self
Creates pathless metadata with unknown size and MIME type.
§Examples
use ailloli_ui_core::UploadFile;
let file = UploadFile::named("photo.png");
assert!(file.path.is_none());Sourcepub fn from_path(path: PathBuf) -> Self
pub fn from_path(path: PathBuf) -> Self
Creates metadata from a path without reading its target.
Self::name is the final UTF-8 path component, or an empty string
when that component is absent or not valid UTF-8. Size and MIME type
remain unknown.
§Examples
use std::path::PathBuf;
use ailloli_ui_core::UploadFile;
let file = UploadFile::from_path(PathBuf::from("images/photo.png"));
assert_eq!(file.name, "photo.png");Trait Implementations§
Source§impl Clone for UploadFile
impl Clone for UploadFile
Source§fn clone(&self) -> UploadFile
fn clone(&self) -> UploadFile
Returns a copy 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 moreSource§impl Debug for UploadFile
impl Debug for UploadFile
Source§impl PartialEq for UploadFile
impl PartialEq for UploadFile
impl Eq for UploadFile
impl StructuralPartialEq for UploadFile
Auto Trait Implementations§
impl Freeze for UploadFile
impl RefUnwindSafe for UploadFile
impl Send for UploadFile
impl Sync for UploadFile
impl Unpin for UploadFile
impl UnwindSafe for UploadFile
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