Skip to main content

Module convert

Module convert 

Source
Expand description

Conversion helpers between ferridriver core types and rquickjs values.

Traits§

FerriResultExt
Adapter: Result<T, FerriError> into rquickjs::Result<T>.

Functions§

extract_page_function
Extract (fn_source, is_function_hint) from an evaluate pageFunction arg that can be a JS string or a JS function — matches Playwright’s String(pageFunction) + typeof pageFunction === 'function' check. For functions, invokes the engine’s Function.prototype.toString() via global String(...).
init_script_from_js
Lower an addInitScript-style JS argument into ferridriver::options::InitScriptSource plus an optional JSON arg. Mirrors Playwright’s Function | string | { path?: string, content?: string } union from /tmp/playwright/packages/playwright-core/src/client/page.ts:520 — all semantic lowering (function body via .toString(), path/content precedence, null-vs-undefined preservation for arg) happens here synchronously so the async binding method can immediately hand owned, Send-safe values to Rust core.
ms_f64_to_u64
Convert a JS millisecond value (f64) into a u64, clamping negatives to 0. Single home for the otherwise-repeated f64->u64 timeout cast so call sites stay lint-clean.
name_value_array_to_js
Build a JS Array<{ name, value }> straight from name/value pairs via rquickjs-serde — no serde_json::json! / serde_json::Value middle allocation. Used by request/response/apiResponse headersArray().
parse_check_options
Parse Playwright’s CheckOptions / UncheckOptions / SetCheckedOptions JS bag into the core struct.
parse_click_options
Parse Playwright’s ClickOptions JS bag into the core struct. Accepts Opt<Value> so callers pass Opt(options) verbatim; None, undefined, or nullOk(None). Unknown button / modifier strings raise a typed rquickjs::Error with the exact Playwright message so JS-side assertions see /Unknown (button|modifier)/ for drift detection.
parse_dblclick_options
Parse Playwright’s DblClickOptions JS bag into the core struct.
parse_dispatch_event_options
Parse Playwright’s DispatchEventOptions JS bag into the core struct.
parse_drop_options
Parse Playwright’s DropOptions JS bag into the core struct.
parse_drop_payload
Parse Playwright’s native DropPayload ({ files?: string | string[] | FilePayload | FilePayload[], data?: { [mimeType: string]: string } }) into the core struct. Both fields are optional.
parse_fill_options
Parse Playwright’s FillOptions JS bag into the core struct.
parse_hover_options
Parse Playwright’s HoverOptions JS bag into the core struct.
parse_input_files
Parse the polymorphic files arg for setInputFiles: string | string[] | FilePayload | FilePayload[].
parse_press_options
Parse Playwright’s PressOptions JS bag into the core struct.
parse_select_option_options
Parse Playwright’s SelectOptionOptions JS bag into the core struct.
parse_select_option_values
Parse a polymorphic selectOption values JS argument: string | string[] | { value?, label?, index? } | Array<...>.
parse_set_input_files_options
Parse Playwright’s SetInputFilesOptions JS bag into the core struct.
parse_tap_options
Parse Playwright’s TapOptions JS bag into the core struct.
parse_type_options
Parse Playwright’s TypeOptions JS bag — same shape as PressOptions.
quickjs_arg_to_serialized
Lower a QuickJS JS argument into a ferridriver::protocol::SerializedArgument ready for page.evaluate(fn, arg) / page.evaluateHandle(fn, arg) etc.
serde_from_js
Inverse of serde_to_js — deserialize a JS value into a Rust type via rquickjs-serde (direct Value -> T). Integral-float -> integer coercion, undefined/function-property drop, Proxy and cycle handling all hold (covered by the rquickjs-serde test suite), so the option-bag call sites keep their prior semantics without our own hand-rolled walker.
serde_to_js
Convert any serde::Serialize value into a JS value via rquickjs-serde — direct T -> rquickjs::Value, no JSON string and no serde_json::Value middle allocation. Used for binding returns (cookies, storage state, parsed JSON bodies).
serialized_value_to_quickjs
Convert a ferridriver::protocol::SerializedValue into a native QuickJS JS value — Date / RegExp / BigInt / URL / Error / typed arrays / NaN / ±Infinity / undefined / -0 all round-trip as their native JS form. Mirrors Playwright’s parseSerializedValue at /tmp/playwright/packages/playwright-core/src/protocol/serializers.ts:19.
to_rq_error
Convert a FerriError into an rquickjs::Error suitable for throwing out of a binding method.