Skip to main content

PresentSpec

Enum PresentSpec 

Source
pub enum PresentSpec {
    Dialog {
        title: String,
        message: Option<String>,
        buttons: Vec<PresentButton>,
        sheet: bool,
    },
    Prompt {
        title: String,
        message: Option<String>,
        placeholder: String,
        initial: String,
        ok: String,
        cancel: String,
    },
    OpenFile {
        title: String,
        filters: Vec<FileFilter>,
    },
    SaveFile {
        title: String,
        suggested_name: String,
        src_path: String,
        filters: Vec<FileFilter>,
    },
}
Expand description

What a backend should present for a req. Kept toolkit-agnostic; the pieces layer maps a chosen button index back to a typed payload.

Variants§

§

Dialog

Alert / confirmation / action sheet: title + optional message + ordered buttons. sheet = present from the bottom on mobile (desktop falls back to an alert).

Fields

§title: String
§message: Option<String>
§sheet: bool
§

Prompt

A dialog with a single text field.

Fields

§title: String
§message: Option<String>
§placeholder: String
§initial: String
§cancel: String
§

OpenFile

Native “open file” picker (docs/files.md). The backend must answer with PresentResult::Files whose entries are readable local paths — desktop returns the chosen path directly; iOS/Android copy the selection into app storage first, so the pieces layer can read it with std::fs regardless of platform.

Fields

§title: String
§filters: Vec<FileFilter>
§

SaveFile

Native “save file” picker (docs/files.md). src_path is a Day-written temp file holding the bytes to save; iOS/Android deliver it to the chosen destination natively, and the pieces layer best-effort copies it to a chosen local path otherwise.

Fields

§title: String
§suggested_name: String
§src_path: String
§filters: Vec<FileFilter>

Implementations§

Source§

impl PresentSpec

Source

pub fn title(&self) -> &str

Backend-facing flattening for the C ABI: (title, message, button labels, button roles as ints, sheet-or-prompt fields). Pure-Rust backends read the enum directly.

Source

pub fn message(&self) -> Option<&str>

Source

pub fn buttons_joined(&self) -> String

Button labels joined with the unit separator (0x1f) — the encoding the nav menu and combobox shims already use for string lists.

Source

pub fn roles_joined(&self) -> String

Button roles as ints (0 default, 1 cancel, 2 destructive), joined with commas.

Source

pub fn filters(&self) -> &[FileFilter]

The file filters, if this is a file dialog.

Source

pub fn suggested_name(&self) -> &str

The suggested file name for a save dialog (empty otherwise).

Source

pub fn src_path(&self) -> &str

The Day-written temp source path for a save dialog (empty otherwise).

Source

pub fn filters_joined(&self) -> String

Filters flattened for the C ABI: each filter is name|ext1,ext2, joined by the unit separator. A trailing | (no extensions) means “all files”. Empty when unfiltered.

Trait Implementations§

Source§

impl Clone for PresentSpec

Source§

fn clone(&self) -> PresentSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PresentSpec

Source§

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

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

impl PartialEq for PresentSpec

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 PresentSpec

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> 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.
Day API ↩ Guides· daybrite.dev