Skip to main content

Hyperlink

Struct Hyperlink 

Source
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.

Implementations§

Source

pub fn uri(&self) -> &str

The link target, exactly as the application declared it — never validated, never resolved. Whether it is a URL a consumer is willing to open is that consumer’s policy (ADR-0017), the same way colour resolution is.

Trait Implementations§

Source§

fn clone(&self) -> Hyperlink

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

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

fn eq(&self, other: &Hyperlink) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.