Skip to main content

DataTransfer

Struct DataTransfer 

Source
pub struct DataTransfer { /* private fields */ }
Expand description

DataTransfer: the data of a clipboard or drag operation, by format (a MIME type), in the order each format was first set, and its files.

It is shared as a DOM DataTransfer is, so its setters take &self: a copy fills the one the platform’s clipboard event carries, and the caller reads it afterwards.

Implementations§

Source§

impl DataTransfer

Source

pub fn new() -> Self

new DataTransfer(): one with no data.

Source

pub fn types(&self) -> Vec<String>

types: the formats set so far, in order, then "Files" when there are files, as browsers report it.

Source

pub fn get_data(&self, format: &str) -> String

getData(format): the data for format, or "".

Source

pub fn set_data(&self, format: &str, data: &str)

setData(format, data): sets the data for format, keeping its place if it was set before.

Source

pub fn clear_data(&self, format: Option<&str>)

clearData(format): removes the data for format, or with None all of it (not the files).

Source

pub fn files(&self) -> Vec<DataTransferFile>

files.

Source

pub fn set_files(&self, files: Vec<DataTransferFile>)

Sets files (what items.add(file) builds up in a browser).

Source

pub fn drop_effect(&self) -> String

dropEffect ("none" at first).

Source

pub fn set_drop_effect(&self, drop_effect: &str)

Source

pub fn effect_allowed(&self) -> String

effectAllowed ("uninitialized" at first).

Source

pub fn set_effect_allowed(&self, effect_allowed: &str)

Trait Implementations§

Source§

impl Debug for DataTransfer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DataTransfer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.