pub struct DataOffer {
    pub(crate) offer: WlDataOffer,
    inner: Arc<Mutex<Inner>>,
}
Expand description

A data offer for receiving data though copy/paste or drag and drop

Fields§

§offer: WlDataOffer§inner: Arc<Mutex<Inner>>

Implementations§

source§

impl DataOffer

source

pub(crate) fn new(offer: Main<WlDataOffer>) -> DataOffer

source

pub fn with_mime_types<F, T>(&self, f: F) -> Twhere F: FnOnce(&[String]) -> T,

Access the list of mime types proposed by this offer

source

pub fn get_available_actions(&self) -> DndAction

Get the list of available actions for this offer

source

pub fn get_current_action(&self) -> DndAction

Get the currently set final action for this offer

source

pub fn accept(&self, mime_type: Option<String>)

Accept a mime type for receiving data through this offer

source

pub fn receive(&self, mime_type: String) -> Result<ReadPipe>

Request to receive the data of a given mime type

You can do this several times, as a reaction to motion of the dnd cursor, or to inspect the data in order to choose your response.

Note that you should not read the contents right away in a blocking way, as you may deadlock your application doing so. At least make sure you flush your events to the server before doing so.

Fails if too many file descriptors were already open and a pipe could not be created.

source

pub unsafe fn receive_to_fd(&self, mime_type: String, writefd: RawFd)

Receive data to the write end of a raw file descriptor. If you have the read end, you can read from it.

You can do this several times, as a reaction to motion of the dnd cursor, or to inspect the data in order to choose your response.

Note that you should not read the contents right away in a blocking way, as you may deadlock your application doing so. At least make sure you flush your events to the server before doing so.

Safety

The provided file destructor must be a valid FD for writing, and will be closed once the contents are written.

source

pub fn set_actions(&self, supported: DndAction, preferred: DndAction)

Notify the send and compositor of the dnd actions you accept

You need to provide the set of supported actions, as well as a single preferred action.

source

pub fn finish(&self)

Notify that you are finished with this offer, and will no longer be using it

Note that it is a protocol error to finish if no action or mime type was accepted.

Trait Implementations§

source§

impl Debug for DataOffer

source§

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

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

impl Drop for DataOffer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.