pub struct Hyperlink { /* private fields */ }Expand description
A declared OSC 8 hyperlink, as handed to a consumer.
Owned, not borrowed, and that is the point: the URI lives in a row’s side map, so
a &str into it would be tied to &Engine and a caller could not hold the link
across the next feed() — which is precisely what a hover handler does. Measured on
the alternative: reading a borrow costs 0.75 ns, but keeping it does not compile, so
the caller copies the string instead at 62.6 ns. Handing back this handle is 17.9 ns
— cheaper than the workaround it removes, on a call made once per hover.
Cloning is a refcount bump; the allocation is shared with every cell of the same OSC 8 open and released when the last row holding it dies (#628).
A struct rather than a bare Arc<str> for two reasons: it keeps Arc out of the
published signature, and OSC 8’s id= parameter (#635) lands here as a field without
changing the return type again. Same shape as alacritty’s Hyperlink, for the same
reasons (alacritty_terminal/src/term/cell.rs).
Link identity is deliberately not exposed yet. Two OSC 8 opens of an identical
URI are two links here, so uri() == uri() cannot answer “is this cell part of the
same link as that one?” — an Arc::ptr_eq accessor would. It is left out because no
consumer asks it today (nothing outside this crate’s tests calls link_at at all),
and unlike this type’s shape, adding a method later is not a breaking change. The
asymmetry decides it: shipping an accessor nobody uses is hard to undo, adding one
when a caller appears is free.