Skip to main content

fret_core/
incoming_open.rs

1//! Portable “open-in” / incoming-open contracts.
2//!
3//! Incoming-open requests originate from the OS (file association open, share-target intents, etc.).
4//! The portable surface is token-based: runners keep privileged platform handles behind tokens and
5//! apps request bytes via effects in the runtime layer.
6
7use crate::{
8    ExternalDragFile, ExternalDropFileData, ExternalDropReadError, ExternalDropReadLimits,
9    ids::IncomingOpenToken,
10};
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum IncomingOpenKind {
14    FileLike,
15    TextLike,
16}
17
18#[derive(Debug, Clone, PartialEq)]
19pub enum IncomingOpenItem {
20    File(ExternalDragFile),
21    Text {
22        /// MIME type when known (e.g. `"text/plain"`). Platforms may leave this unset.
23        media_type: Option<String>,
24        /// Size estimate in bytes when known.
25        estimated_size_bytes: Option<u64>,
26    },
27}
28
29#[derive(Debug, Clone, PartialEq)]
30pub struct IncomingOpenDataEvent {
31    pub token: IncomingOpenToken,
32    pub files: Vec<ExternalDropFileData>,
33    pub texts: Vec<String>,
34    pub errors: Vec<ExternalDropReadError>,
35    pub limits: Option<ExternalDropReadLimits>,
36}