Skip to main content

tab_open

Function tab_open 

Source
pub async fn tab_open(
    backend: &TabBackend,
    registry: &Registry,
    browser_name: &str,
    name: Option<&str>,
    url: Option<&str>,
) -> Result<TabRow>
Expand description

Open a named tab (get-or-create), navigating if url differs from the existing tab’s last_url. Returns the up-to-date row.

Behaviour:

  • name = None: always create a fresh tab; assign a cute name.
  • name = Some(n):
    • if row (browser, n) exists and its target_id is alive → navigate-on-mismatch and return.
    • if row exists but target_id is stale → close (best-effort), delete row, fall through to create.
    • if no row → create.
  • url = None: defaults to about:blank.

On create, if daemon_created rows ≥ HARD_CAP, close the LRU first (Target.closeTarget + tab_delete) to free a slot.