Skip to main content

MockToolkit

Struct MockToolkit 

Source
pub struct MockToolkit {
    pub state: Rc<RefCell<MockState>>,
}
Expand description

The mock backend. Cloneable observer half: construct with MockToolkit::new and keep the returned MockProbe to inspect state after day-core takes ownership of the toolkit.

Fields§

§state: Rc<RefCell<MockState>>

Implementations§

Source§

impl MockToolkit

Source

pub fn new() -> (Self, MockProbe)

Trait Implementations§

Source§

impl Platform for MockToolkit

Source§

const TARGET: &'static str = "mock-mock"

e.g. "macos-appkit" — the process-constant target id.
Source§

const TOOLKIT: &'static str = "mock"

The toolkit half of the target, e.g. "appkit".
Source§

fn run( self, options: WindowOptions, ready: Box<dyn FnOnce(Self, MockHandle, Size)>, )

Source§

fn post(f: Box<dyn FnOnce() + Send>)

Post a closure onto the native main loop. Callable from ANY thread; this is the single door the reactive scheduler and Setter deliveries ride (§3.3).
§

fn post_delayed(ms: u32, f: Box<dyn FnOnce() + Send>)

Post f onto the native main loop after (at least) ms milliseconds — the timer door behind day::sleep (docs/async.md). The default spawns a helper thread that sleeps and rides [Platform::post] home, which is correct on every threaded platform with zero backend code; a single-threaded host (web) overrides it with the platform’s own timer.
§

fn request_frame(_cb: Box<dyn FnOnce(f64)>)

Request a single main-thread callback aligned to the next display refresh (vsync), carrying the frame timestamp in seconds. The day-core animation driver re-arms it each tick while animations / game frame-clocks are live and stops requesting when none remain (no idle wakeups → battery). Main-thread only. A backend without a display link may approximate with a ~16 ms timer. Defaulted no-op: the canvas/self-driven animation path is inert until a backend provides it (native-widget animation via AnimSpec is unaffected). (§8.4)
§

fn locale_hints(&self) -> Vec<String>

Ordered OS locale preference list (BCP-47), for fluent-langneg (§12.2).
Source§

impl Toolkit for MockToolkit

Source§

type Handle = MockHandle

Source§

fn capability(&self, cap: Cap) -> Support

Source§

fn realize( &mut self, kind: PieceKind, props: &dyn Any, id: NodeId, ) -> MockHandle

Source§

fn update( &mut self, h: &MockHandle, kind: PieceKind, patch: &dyn Any, anim: Option<&AnimSpec>, )

Source§

fn release(&mut self, h: MockHandle)

Called from the turn-boundary release queue; backends may defer destruction further.
Source§

fn insert(&mut self, parent: &MockHandle, child: &MockHandle, index: usize)

Source§

fn remove(&mut self, parent: &MockHandle, child: &MockHandle)

Source§

fn move_child(&mut self, parent: &MockHandle, child: &MockHandle, to: usize)

Source§

fn measure(&mut self, h: &MockHandle, kind: PieceKind, p: Proposal) -> Size

Source§

fn set_frame(&mut self, h: &MockHandle, frame: Rect, anim: Option<&AnimSpec>)

Source§

fn set_opacity(&mut self, h: &MockHandle, opacity: f64, anim: Option<&AnimSpec>)

Source§

fn set_transform( &mut self, h: &MockHandle, t: Transform, _size: Size, anim: Option<&AnimSpec>, )

Source§

fn set_selectable(&mut self, h: &MockHandle, selectable: bool)

Source§

fn set_scroll_content(&mut self, h: &MockHandle, content: Size)

Source§

fn scroll_to(&mut self, h: &MockHandle, target: Rect, _animated: bool)

Source§

fn scroll_offset(&mut self, h: &MockHandle) -> Point

Source§

fn enable_gesture(&mut self, h: &MockHandle, _node: NodeId, kind: GestureKind)

Source§

fn focus(&mut self, h: &MockHandle, _node: NodeId, focused: bool)

Source§

fn set_event_sink(&mut self, sink: EventSink)

Source§

fn attach_list(&mut self, host: &MockHandle, source: ListSource)

Source§

fn adopt(&mut self, raw: RawHandle) -> MockHandle

Source§

fn set_a11y(&mut self, h: &MockHandle, a11y: &A11yProps)

Source§

fn replay(&mut self, h: &MockHandle, ops: &[DrawOp], size: Size)

Source§

fn snapshot_window(&mut self) -> Result<Vec<u8>, String>

Source§

fn open_window( &mut self, id: NodeId, options: &WindowOptions, kind: WindowKind, ) -> WindowOpenReply<MockHandle>

Open a native OS window per options + kind: create and show the window, wire ITS events to idWindowResized (content size, points), WindowClosed (after the native close), WindowFocused (key/active changes) — and answer with its CONTENT container handle, the same contract as the ready root container. Backends whose window creation is asynchronous (a scene, an activity, an ability) answer [WindowOpenReply::Pending] and complete later through day_core::finish_window_open(id, raw, size) (the [Toolkit::adopt] seam). The default answers Unsupported — day-core then presents the content as a fullscreen cover in the primary window instead.
Source§

fn close_window(&mut self, host: &MockHandle)

Close the native window whose CONTENT container is host (a handle open_window produced). Asynchronous: the platform confirms with Event::WindowClosed on the window’s root node, and day-core tears the subtree down THEN. Idempotent; unknown hosts are ignored. Never called with the primary window’s container.
Source§

fn focus_window(&mut self, host: &MockHandle)

Bring the window whose CONTENT container is host to front and make it key/active — the focus half of open-or-focus singleton windows. Default no-op.
Source§

fn set_window_title(&mut self, host: &MockHandle, title: &str)

Retitle the window whose CONTENT container is host. Default no-op.
Source§

fn snapshot_window_of(&mut self, host: &MockHandle) -> Result<Vec<u8>, String>

Snapshot the window whose CONTENT container is host (the dayscript screenshot step’s window: target). The default answers the primary snapshot, so backends that never open windows stay correct without changes.
Source§

fn present(&mut self, req: u64, spec: &PresentSpec)

Source§

fn dismiss(&mut self, req: u64)

Source§

fn open_url(&mut self, url: &str)

Open url in the platform’s default handler — the system browser for http(s), the mail client for mailto:, etc. Backs the link piece. Fire and forget: there is no result, and an unopenable URL is ignored. The default no-ops so a backend that hasn’t wired it up still compiles.
Source§

fn defer_system_gestures(&mut self, edges: Edges)

Ask the OS to require a second swipe for its edge gestures on edges (docs/cover.md) — the union requested by every mounted defers_system_gestures modifier, re-sent whenever that set changes (Edges::NONE when the last one unmounts). iOS defers the home indicator / notification edges; Android enters swipe-to-reveal immersive mode while non-empty. The default no-ops (desktop has no system edge gestures).
Source§

fn set_app_menu(&mut self, items: &[MenuItem])

The application menu (macOS/Windows/Linux menu bar; the app-bar overflow on Android; the UIMenuBuilder main menu on iPadOS/Catalyst). Replaces any previous app menu.
Source§

fn set_context_menu( &mut self, h: &MockHandle, _node: NodeId, items: &[MenuItem], )

A context menu for h, shown on secondary-click (desktop) or long-press (mobile). Passing an empty slice removes it.
Source§

fn supports_lifecycle(&self, _phase: Lifecycle) -> bool

Source§

fn read_a11y(&self, h: &MockHandle) -> A11ySnapshot

Read a widget’s ACTUAL native accessibility properties for a11y_audit (§14.2) to diff against Day’s expectation. Default: unsupported (found = false) — the audit skips the node.
Source§

fn ui_idle(&mut self) -> bool

Whether the UI has settled — no native transition (modal present/dismiss, nav push) still animating. The dayscript screenshot step polls this before capturing so shots never catch a half-faded dialog or half-pushed page. Backends without async transitions (or without a way to know) report true.
Source§

fn on_suspend(&mut self)

Source§

fn on_resume(&mut self)

Source§

fn on_memory_warning(&mut self)

§

fn set_route(&mut self, _route: &str)

§

fn set_toolbar(&mut self, _h: &Self::Handle, _items: &[ToolbarItem])

Install items as the window’s toolbar, replacing any previous one. An empty slice removes it. Items are identified by [ToolbarItem::id]; a backend that can reuse the native item already carrying an id should, so a replace does not drop the search field’s focus.
§

fn update_toolbar(&mut self, _h: &Self::Handle, _patch: &ToolbarPatch)

Apply a targeted change to one live toolbar item — the path a bound signal writes through, so syncing a search field does not rebuild the bar. No-op if the item is not present.
§

fn dark_mode(&mut self) -> bool

Whether the platform is rendering in DARK appearance right now. Apps painting custom surfaces (opaque overlay panels, scrims) branch on this so their fills track the theme the DEFAULT text colors already follow — hardcoding either theme’s surface produces dark-on-dark or light-on-light text on the other. Queried at build time (a piece rebuilt after a theme change re-queries). The default honors a DAY_THEME launch override and otherwise answers light.
§

fn set_appearance(&mut self, _dark: Option<bool>)

App-level appearance override: Some(true) forces dark, Some(false) forces light, None returns to following the system. Backends restyle their native widgets in place and answer the override from dark_mode; app-painted surfaces pick it up on their next rebuild. Cap::Appearance reports whether the backend honors this; the default ignores the call.

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