Enum FileEvent

Source
#[non_exhaustive]
pub enum FileEvent { Entered { pos: Option<Point>, files: Vec<UploadFile>, }, Moved { pos: Option<Point>, files: Vec<UploadFile>, }, Left, Dropped { pos: Option<Point>, files: Vec<UploadFile>, }, Hover { pos: Point, files: Vec<UploadFile>, }, HoverCancelled, Drop { pos: Point, files: Vec<UploadFile>, }, }
Expand description

Platform-neutral file hover/drop event.

Current variants are Entered, Moved, Left, and Dropped; Hover, HoverCancelled, and Drop remain compatibility variants.

§Examples

use ailloli_ui_core::{event::FileEvent, Point, UploadFile};
let event = FileEvent::dropped(Some(Point::new(2.0, 3.0)), [UploadFile::named("a.txt")]);
assert_eq!(event.files()[0].name, "a.txt");

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Entered

A batch of files entered the logical window.

Fields

§pos: Option<Point>

Logical pointer position when supplied by the provider.

§files: Vec<UploadFile>

Files in provider order; the batch may be empty.

§

Moved

A hovering batch moved within the logical window.

Fields

§pos: Option<Point>

Logical pointer position when supplied by the provider.

§files: Vec<UploadFile>

Current files in provider order; the batch may be empty.

§

Left

The current file batch left the logical window.

§

Dropped

A batch of files was dropped in the logical window.

Fields

§pos: Option<Point>

Logical pointer position when supplied by the provider.

§files: Vec<UploadFile>

Dropped files in provider order; the batch may be empty.

§

Hover

One or more files are hovering over the window at logical pos.

New adapters should use FileEvent::Entered and FileEvent::Moved.

Fields

§pos: Point

Logical pointer position reported by the legacy adapter.

§files: Vec<UploadFile>

Hovering files in provider order.

§

HoverCancelled

File hover was cancelled by the platform.

New adapters should use FileEvent::Left.

§

Drop

One or more files were dropped at logical pos.

New adapters should use FileEvent::Dropped.

Fields

§pos: Point

Logical pointer position reported by the legacy adapter.

§files: Vec<UploadFile>

Dropped files in provider order.

Implementations§

Source§

impl FileEvent

Source

pub fn entered( pos: Option<Point>, files: impl IntoIterator<Item = UploadFile>, ) -> Self

Creates an ordered batch that entered the logical window.

None preserves that the provider did not supply a pointer position; it is not replaced with an origin or stale coordinate.

§Examples
use ailloli_ui_core::{event::FileEvent, UploadFile};
let event = FileEvent::entered(None, [UploadFile::named("a.txt")]);
assert_eq!(event.pos(), None);
Source

pub fn moved( pos: Option<Point>, files: impl IntoIterator<Item = UploadFile>, ) -> Self

Creates an ordered hovering batch movement.

§Examples
use ailloli_ui_core::{event::FileEvent, Point, UploadFile};
let event = FileEvent::moved(Some(Point::new(1.0, 2.0)), [UploadFile::named("a.txt")]);
assert_eq!(event.pos(), Some(Point::new(1.0, 2.0)));
Source

pub const fn left() -> Self

Creates a notification that the current batch left the window.

Leave events carry neither files nor a position.

§Examples
use ailloli_ui_core::event::FileEvent;
assert!(FileEvent::left().is_left());
Source

pub fn dropped( pos: Option<Point>, files: impl IntoIterator<Item = UploadFile>, ) -> Self

Creates an ordered batch dropped in the logical window.

§Examples
use ailloli_ui_core::{event::FileEvent, UploadFile};
assert_eq!(FileEvent::dropped(None, [UploadFile::named("a.txt")]).files().len(), 1);
Source

pub fn pos(&self) -> Option<Point>

Logical pointer position supplied by the provider, when known.

§Examples
use ailloli_ui_core::{event::FileEvent, Point, UploadFile};
let event = FileEvent::entered(Some(Point::new(3.0, 4.0)), [UploadFile::named("a")]);
assert_eq!(event.pos(), Some(Point::new(3.0, 4.0)));
Source

pub fn files(&self) -> &[UploadFile]

Ordered files carried by the event, or an empty slice for leave events.

§Examples
use ailloli_ui_core::event::FileEvent;
assert!(FileEvent::left().files().is_empty());
Source

pub const fn is_left(&self) -> bool

Returns true for both current and legacy leave variants.

§Examples
use ailloli_ui_core::event::FileEvent;
assert!(FileEvent::left().is_left());

Trait Implementations§

Source§

impl Clone for FileEvent

Source§

fn clone(&self) -> FileEvent

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileEvent

Source§

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

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

impl PartialEq for FileEvent

Source§

fn eq(&self, other: &FileEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for FileEvent

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 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.