Skip to main content

Effect

Enum Effect 

Source
pub enum Effect {
Show 45 variants Redraw(AppWindowId), Window(WindowRequest), Command { window: Option<AppWindowId>, command: CommandId, }, QuitApp, ShowAboutPanel, HideApp, HideOtherApps, UnhideAllApps, SetMenuBar { window: Option<AppWindowId>, menu_bar: MenuBar, }, ClipboardWriteText { window: AppWindowId, token: ClipboardToken, text: String, }, ClipboardReadText { window: AppWindowId, token: ClipboardToken, }, PrimarySelectionSetText { text: String, }, PrimarySelectionGetText { window: AppWindowId, token: ClipboardToken, }, ExternalDropReadAll { window: AppWindowId, token: ExternalDropToken, }, ExternalDropReadAllWithLimits { window: AppWindowId, token: ExternalDropToken, limits: ExternalDropReadLimits, }, ExternalDropRelease { token: ExternalDropToken, }, OpenUrl { url: String, target: Option<String>, rel: Option<String>, }, ShareSheetShow { window: AppWindowId, token: ShareSheetToken, items: Vec<ShareItem>, }, FileDialogOpen { window: AppWindowId, options: FileDialogOptions, }, FileDialogReadAll { window: AppWindowId, token: FileDialogToken, }, FileDialogReadAllWithLimits { window: AppWindowId, token: FileDialogToken, limits: ExternalDropReadLimits, }, FileDialogRelease { token: FileDialogToken, }, IncomingOpenReadAll { window: AppWindowId, token: IncomingOpenToken, }, IncomingOpenReadAllWithLimits { window: AppWindowId, token: IncomingOpenToken, limits: ExternalDropReadLimits, }, IncomingOpenRelease { token: IncomingOpenToken, }, DiagIncomingOpenInject { window: AppWindowId, items: Vec<DiagIncomingOpenItem>, }, DiagInjectEvent { window: AppWindowId, event: Event, }, DiagClipboardForceUnavailable { window: AppWindowId, enabled: bool, }, TextAddFontAssets { requests: Vec<AssetRequest>, }, TextRescanSystemFonts, ViewportInput(ViewportInputEvent), Dock(DockOp), ImeAllow { window: AppWindowId, enabled: bool, }, ImeRequestVirtualKeyboard { window: AppWindowId, visible: bool, }, ImeSetCursorArea { window: AppWindowId, rect: Rect, }, WindowMetricsSetInsets { window: AppWindowId, safe_area_insets: Option<Option<Edges>>, occlusion_insets: Option<Option<Edges>>, }, CursorSetIcon { window: AppWindowId, icon: CursorIcon, }, ImageRegisterRgba8 { window: AppWindowId, token: ImageUploadToken, width: u32, height: u32, bytes: Vec<u8>, color_info: ImageColorInfo, alpha_mode: AlphaMode, }, ImageUpdateRgba8 { window: Option<AppWindowId>, token: ImageUpdateToken, image: ImageId, stream_generation: u64, width: u32, height: u32, update_rect_px: Option<RectPx>, bytes_per_row: u32, bytes: Vec<u8>, color_info: ImageColorInfo, alpha_mode: AlphaMode, }, ImageUpdateNv12 {
Show 13 fields window: Option<AppWindowId>, token: ImageUpdateToken, image: ImageId, stream_generation: u64, width: u32, height: u32, update_rect_px: Option<RectPx>, y_bytes_per_row: u32, y_plane: Vec<u8>, uv_bytes_per_row: u32, uv_plane: Vec<u8>, color_info: ImageColorInfo, alpha_mode: AlphaMode,
}, ImageUpdateI420 {
Show 15 fields window: Option<AppWindowId>, token: ImageUpdateToken, image: ImageId, stream_generation: u64, width: u32, height: u32, update_rect_px: Option<RectPx>, y_bytes_per_row: u32, y_plane: Vec<u8>, u_bytes_per_row: u32, u_plane: Vec<u8>, v_bytes_per_row: u32, v_plane: Vec<u8>, color_info: ImageColorInfo, alpha_mode: AlphaMode,
}, ImageUnregister { image: ImageId, }, RequestAnimationFrame(AppWindowId), SetTimer { window: Option<AppWindowId>, token: TimerToken, after: Duration, repeat: Option<Duration>, }, CancelTimer { token: TimerToken, },
}
Expand description

Effects emitted by the portable runtime surface.

Effects are collected by the host (e.g. fret-app::App) and are expected to be handled by a runner/backend integration layer (native or web).

§Completion events (runner contract)

Many effects represent an asynchronous request to the platform and are completed later by a corresponding fret_core::Event. Runners/backends should treat these as best-effort.

Common mappings:

  • ClipboardReadText { token, .. }fret_core::Event::ClipboardReadText { token, .. } or fret_core::Event::ClipboardReadFailed { token, .. }
  • PrimarySelectionGetText { token, .. }fret_core::Event::PrimarySelectionText { token, .. } or fret_core::Event::PrimarySelectionTextUnavailable { token, .. }
  • ShareSheetShow { token, .. }fret_core::Event::ShareSheetCompleted { token, .. }
  • FileDialogOpen { .. }fret_core::Event::FileDialogSelection(..) or fret_core::Event::FileDialogCanceled
  • FileDialogReadAll { token, .. }fret_core::Event::FileDialogData(..)
  • IncomingOpenReadAll { token, .. }fret_core::Event::IncomingOpenData(..) or fret_core::Event::IncomingOpenUnavailable { token, .. }
  • SetTimer { token, .. }fret_core::Event::Timer { token }
  • ImageRegister* { token, .. }fret_core::Event::ImageRegistered { token, .. } or fret_core::Event::ImageRegisterFailed { token, .. }
  • ImageUpdate* { token, .. } → optionally fret_core::Event::ImageUpdateApplied { token, .. } or fret_core::Event::ImageUpdateDropped { token, .. } when the runner supports these acks (capability-gated to avoid flooding the event loop).

Variants§

§

Redraw(AppWindowId)

Request a window redraw (one-shot).

This is the lowest-level redraw primitive. Higher-level UI code typically calls App::request_redraw (or Cx::request_redraw / Cx::request_frame), which eventually results in this effect being handled by the runner/backend.

Semantics:

  • This is a one-shot request and may be coalesced by the runner or platform compositor.
  • This does not imply continuous frame progression. If you need to keep repainting without input events (animations, progressive rendering), use Effect::RequestAnimationFrame and re-issue it each frame while active.
§

Window(WindowRequest)

§

Command

Fields

§command: CommandId
§

QuitApp

Request the application to quit (native runners may exit their event loop).

Web runners may ignore this request.

§

ShowAboutPanel

Show the standard native “About” panel when available.

Platform mapping:

  • macOS: NSApplication orderFrontStandardAboutPanel:
  • Other platforms: runners may ignore this request.
§

HideApp

Hide the application (macOS: NSApplication hide:).

Other platforms may ignore this request.

§

HideOtherApps

Hide all other applications (macOS: NSApplication hideOtherApplications:).

Other platforms may ignore this request.

§

UnhideAllApps

Unhide all applications (macOS: NSApplication unhideAllApplications:).

Other platforms may ignore this request.

§

SetMenuBar

Set the application/window menu bar (native runners may map this to an OS menubar).

Notes:

  • This is a platform integration seam; web runners may ignore it.
  • The menu model is data-only (MenuBar) and is typically derived from command metadata (ADR 0023).

Fields

§menu_bar: MenuBar
§

ClipboardWriteText

Requests writing platform clipboard text (best-effort).

Fields

§text: String
§

ClipboardReadText

Requests reading platform clipboard text (best-effort).

Runners/backends should eventually complete this request by emitting a corresponding event carrying token (see ClipboardToken contract in fret-core).

Fields

§

PrimarySelectionSetText

Set Linux primary selection text (copy-on-select).

This is intentionally separate from ClipboardWriteText so selecting text does not overwrite the explicit clipboard used by Ctrl+C / edit.copy.

Fields

§text: String
§

PrimarySelectionGetText

Read Linux primary selection text (middle-click paste).

Fields

§

ExternalDropReadAll

§

ExternalDropReadAllWithLimits

§

ExternalDropRelease

Fields

§

OpenUrl

Requests opening a URL using the platform’s default handler (best-effort).

Callers should ensure the URL is safe/expected. Component-layer helpers may apply additional policies (e.g. rel="noreferrer").

Fields

§target: Option<String>
§

ShareSheetShow

Show the platform-native share sheet (best-effort).

Fields

§

FileDialogOpen

Opens a platform-native file dialog (best-effort).

Runners/backends typically respond by delivering one of:

  • fret_core::Event::FileDialogSelection (token + names), followed by Effect::FileDialogReadAll to obtain bytes, or
  • fret_core::Event::FileDialogCanceled if the user cancels.

Fields

§

FileDialogReadAll

Requests reading all selected file bytes for a previously opened file dialog.

Fields

§

FileDialogReadAllWithLimits

§

FileDialogRelease

Releases runner-owned resources associated with a file dialog token (best-effort).

Fields

§

IncomingOpenReadAll

Read all data associated with an incoming-open token (best-effort).

§

IncomingOpenReadAllWithLimits

§

IncomingOpenRelease

Releases runner-owned resources associated with an incoming-open token (best-effort).

Fields

§

DiagIncomingOpenInject

Diagnostics-only “incoming open” injection (best-effort).

This simulates mobile-style share-target / open-in flows in CI by injecting an Event::IncomingOpenRequest carrying tokenized items.

Runners SHOULD:

  • allocate an IncomingOpenToken,
  • enqueue/deliver Event::IncomingOpenRequest { token, items },
  • and retain the injected payload behind the token so subsequent reads can succeed.

Notes:

  • This is intended for diagnostics/scripts only; real incoming-open requests originate from the OS.
  • Payload bytes are diagnostic fixtures; they are not intended to model platform handles.
§

DiagInjectEvent

Diagnostics-only synthetic event injection (best-effort).

This lets tooling deliver an already-constructed runtime event to a specific window even when that window is not the one currently producing render callbacks.

Fields

§event: Event
§

DiagClipboardForceUnavailable

Diagnostics-only clipboard override to simulate mobile privacy/user-activation denial paths.

Notes:

  • Runners SHOULD treat this as a best-effort toggle and default to enabled=false.
  • When enabled, clipboard reads (ClipboardReadText, PrimarySelectionGetText) SHOULD complete as unavailable rather than attempting platform access.
  • Clipboard writes (ClipboardWriteText) SHOULD complete with a failed outcome rather than attempting platform access.

Fields

§enabled: bool
§

TextAddFontAssets

Resolve logical font assets through the shared runtime asset resolver and add the resulting bytes to the renderer text system.

This is the runtime font-loading lane for callers that want resolver overrides, diagnostics, and packaged mounts to participate before byte injection.

The runner/backend is responsible for resolving each request, applying any successful results to the renderer, and triggering any required invalidation/redraw.

Fields

§requests: Vec<AssetRequest>
§

TextRescanSystemFonts

Request a best-effort rescan of system-installed fonts (native-only).

Web/WASM runners should ignore this effect, as they cannot access system font databases.

Semantics:

  • This is an explicit, user-initiated refresh hook (ADR 0258).
  • Runners should re-enumerate the font catalog and republish FontCatalogMetadata if changes are observed.
  • Runners should also bump renderer text invalidation keys (e.g. TextFontStackKey) so cached shaping/rasterization results cannot be reused after a rescan attempt.
§

ViewportInput(ViewportInputEvent)

§

Dock(DockOp)

§

ImeAllow

Fields

§enabled: bool
§

ImeRequestVirtualKeyboard

Best-effort request to show/hide the platform virtual keyboard.

Notes:

  • This does not replace Effect::ImeAllow, which remains the source of truth for whether the focused widget is a text input.
  • Some platforms (notably Android) may require this request to be issued within a user-activation turn (direct input event handling), otherwise it may be ignored.

Fields

§visible: bool
§

ImeSetCursorArea

Fields

§rect: Rect
§

WindowMetricsSetInsets

Override window insets in WindowMetricsService (safe area / occlusion).

This is primarily used by diagnostics/scripted repros to simulate keyboard occlusion on platforms where the real OS insets are not available in CI.

Semantics:

  • None means “no change”.
  • Some(None) clears the insets but still marks them as “known”.
  • Some(Some(v)) sets the insets to v.

Fields

§safe_area_insets: Option<Option<Edges>>
§occlusion_insets: Option<Option<Edges>>
§

CursorSetIcon

Fields

§

ImageRegisterRgba8

Fields

§width: u32
§height: u32
§bytes: Vec<u8>
§color_info: ImageColorInfo
§alpha_mode: AlphaMode
§

ImageUpdateRgba8

Fields

§image: ImageId
§stream_generation: u64
§width: u32
§height: u32
§update_rect_px: Option<RectPx>
§bytes_per_row: u32
§bytes: Vec<u8>
§color_info: ImageColorInfo
§alpha_mode: AlphaMode
§

ImageUpdateNv12

Fields

§image: ImageId
§stream_generation: u64
§width: u32
§height: u32
§update_rect_px: Option<RectPx>
§y_bytes_per_row: u32
§y_plane: Vec<u8>
§uv_bytes_per_row: u32
§uv_plane: Vec<u8>
§color_info: ImageColorInfo
§alpha_mode: AlphaMode
§

ImageUpdateI420

Fields

§image: ImageId
§stream_generation: u64
§width: u32
§height: u32
§update_rect_px: Option<RectPx>
§y_bytes_per_row: u32
§y_plane: Vec<u8>
§u_bytes_per_row: u32
§u_plane: Vec<u8>
§v_bytes_per_row: u32
§v_plane: Vec<u8>
§color_info: ImageColorInfo
§alpha_mode: AlphaMode
§

ImageUnregister

Fields

§image: ImageId
§

RequestAnimationFrame(AppWindowId)

Request the next animation frame for a window.

Use this for frame-driven updates (animations, progressive rendering) where the UI must keep repainting even if there are no new input events.

This is a one-shot request. Runners/backends should schedule a redraw and keep advancing the frame counter while these requests are being issued.

Platform mapping:

  • Web backends typically map this to requestAnimationFrame.
  • Desktop backends typically translate this into a “redraw on the next event-loop turn” request (and may coalesce multiple requests).
§

SetTimer

Requests a timer callback to be delivered as fret_core::Event::Timer (best-effort).

Fields

§after: Duration
§

CancelTimer

Cancels a previously requested timer (best-effort).

Fields

Trait Implementations§

Source§

impl Clone for Effect

Source§

fn clone(&self) -> Effect

Returns a duplicate 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 Effect

Source§

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

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

impl PartialEq for Effect

Source§

fn eq(&self, other: &Effect) -> 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 Effect

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.