pub struct DroppedFile {
pub name: String,
pub declared_type: Option<String>,
pub bytes: Vec<u8>,
}Expand description
A file a drop carries: its name, the type its author declared for it when they declared one,
and its content. Its size is always its content’s length, as a browser’s File.size is; its
type (DroppedFile::mime_type) is the declared one, and otherwise what a browser names the
file from its name (browser_mime_type).
Fields§
§name: String§declared_type: Option<String>§bytes: Vec<u8>Implementations§
Source§impl DroppedFile
impl DroppedFile
Sourcepub fn named(name: &str) -> DroppedFile
pub fn named(name: &str) -> DroppedFile
A file known by its name alone: no declared type, no content.
Sourcepub fn declared(
name: String,
size: Option<i64>,
declared_type: Option<String>,
bytes: Option<Vec<i64>>,
) -> Result<DroppedFile, String>
pub fn declared( name: String, size: Option<i64>, declared_type: Option<String>, bytes: Option<Vec<i64>>, ) -> Result<DroppedFile, String>
The file a new File with name … and size … and type … and bytes … declares. Its content is
bytes when they are declared; a size declared without them is that many zero bytes. A
declared size that is not the count of the declared bytes describes no file a browser can
hold, and is refused, as is a byte outside 0..=255. A type left undeclared is the one a
browser gives the name, exactly as a file known by its name alone gets it.
Sourcepub fn mime_type(&self) -> &str
pub fn mime_type(&self) -> &str
The file’s type as a handler reads it (file's type): the one its author declared, or the
one a browser gives its name.
Sourcepub fn from_value(value: &RuntimeValue) -> Result<DroppedFile, String>
pub fn from_value(value: &RuntimeValue) -> Result<DroppedFile, String>
The file a raised value names: a File record, read by DroppedFile::declared’s rule
(a field the record leaves out, or holds as nothing, is undeclared), or a Text naming a
file by its name alone (DroppedFile::named).
Sourcepub fn to_value(&self) -> RuntimeValue
pub fn to_value(&self) -> RuntimeValue
The File record a handler binds: name, size, type and bytes.
Trait Implementations§
Source§impl Clone for DroppedFile
impl Clone for DroppedFile
Source§fn clone(&self) -> DroppedFile
fn clone(&self) -> DroppedFile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DroppedFile
impl Debug for DroppedFile
Source§impl Default for DroppedFile
impl Default for DroppedFile
Source§fn default() -> DroppedFile
fn default() -> DroppedFile
Source§impl PartialEq for DroppedFile
impl PartialEq for DroppedFile
impl Eq for DroppedFile
impl StructuralPartialEq for DroppedFile
Auto Trait Implementations§
impl Freeze for DroppedFile
impl RefUnwindSafe for DroppedFile
impl Send for DroppedFile
impl Sync for DroppedFile
impl Unpin for DroppedFile
impl UnsafeUnpin for DroppedFile
impl UnwindSafe for DroppedFile
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.