Skip to main content

Run

Struct Run 

Source
pub struct Run {
Show 17 fields pub text: String, pub role: String, pub bold: bool, pub italic: bool, pub underline: bool, pub strike: bool, pub sup: bool, pub sub: bool, pub src: u32, pub sel: bool, pub hl: Option<String>, pub hl_color: Option<String>, pub mark_color: Option<String>, pub token: Option<String>, pub size: Option<String>, pub font: Option<String>, pub text_color: Option<String>,
}
Expand description

One maximal span of same-styled glyphs on a visual row — the unit the Swift renderer turns into a single styled attributed-string run.

Fields§

§text: String

The run’s text, glyphs concatenated in column order.

§role: String

The glyph’s semantic role as a renderer class id: body, h1…h6, code, link, mark, list, quote, rule.

§bold: bool§italic: bool§underline: bool§strike: bool§sup: bool

Raised off the baseline and drawn smaller — a footnote reference’s [1], or an author’s ^x^. Mutually exclusive with sub; core’s Baseline is one value, and these are its two non-default cases flattened to the flag shape the rest of this record is spelled in.

§sub: bool

Lowered off the baseline and drawn smaller — an author’s ~x~.

§src: u32

The byte offset in the source this run’s first glyph came from.

What a run means, as opposed to how it looks: a link role says a span is drawn as a link but not where it points, and the only way back to that is the source. A frontend drawing part of the document somewhere the caret isn’t — a footnote’s text in a popover — pairs this with LeafDoc::link_destination_at or LeafDoc::footnote_at to make those runs followable.

The alternative was for a frontend to count its way along the row’s text and ask LeafDoc::offset_for_pos, which means converting between three units that only agree on ASCII: this is a byte offset, the run’s text is characters, and a row’s column is a display cell (a wide CJK glyph is two). Handing the offset over is exact, O(1), and needs none of that.

0 for the runs of the source view, whose rows are split from raw text rather than laid out from glyphs.

§sel: bool

Whether this run lies inside the active selection — so the renderer can paint a selection background without re-deriving it from offsets.

§hl: Option<String>

The id of the host highlight covering this run, if one does — see LeafDoc::set_highlights. A highlight splits a run the way the selection does, so a wash begins and ends exactly on its bytes.

§hl_color: Option<String>

That highlight’s rendering hint (#RRGGBB, or None for the theme’s default wash), carried beside the id so a renderer needs no lookup.

§mark_color: Option<String>

The colour the author named on a mark run — "red", "orange", "yellow", "green", "blue", "purple", "brown" — or absent for a plain ==highlight== and for every other role.

A name, unlike hl_color’s #RRGGBB, and that is the difference between the two: a host highlight’s colour is the host’s own choice and arrives as a value to paint, while this one is the document’s word for it and the renderer picks the wash. It rides beside role rather than folding into it ("mark-red") so a renderer that knows nothing about colours still draws the run as the highlight it is.

§token: Option<String>

What a code run is to the language its fenced block is written in — "punctuation", "keyword", "entity", "support", "constant", "string", "comment", "invalid" — or absent for a run the grammar left plain, for every run of a block in a language no grammar covers, for inline code, and for every other role.

A class id like role, and beside it for the reason mark_color is: a renderer that knows nothing about tokens still draws the run as the code it is, and one that does keys a palette on the name.

§size: Option<String>

How large this run is set — one of CSS’s seven keywords ("xx-small", "x-small", "small", "large", "x-large", "xx-large", "xxx-large"), or the exact size the author asked for ("14pt", "13.5pt") — and absent for the theme’s own size, which is every run there was before the presentation vocabulary.

A token rather than an enum, for mark_color’s reason and one more: a keyword says how much bigger and leaves how big to the theme (leaf_core::SizeStep::scale has CSS’s own ratios for a renderer that wants a default ramp), while a pt size is exactly that many points of the sheet. A renderer reads its table first and parses the suffix when the table has no entry.

§font: Option<String>

The face this run is set in — one of CSS’s four generics ("serif", "sans-serif", "monospace", "cursive"), or a family the author named ("Garamond") — and absent for the theme’s body face.

A generic is the theme’s to name, so serif is whichever serif this platform’s theme has and opens everywhere. A family name is resolved through the platform’s font registry and falls back to the body face where it is not installed, which is the portability the author traded away knowingly.

§text_color: Option<String>

The run’s foreground colour — one of the seven names mark_color carries, or six lowercase hex digits behind a # ("#c03030") — and absent for the theme’s text colour.

A name is two inks, one per appearance, and the theme owns both; a triple is painted as written in the light appearance and in the dark one alike, which is what “exact” means.

Not mark_color, though they share a vocabulary on purpose: that is a highlight’s background and reaches a run through its mark role, this is what the letters themselves are painted. A renderer with a red for a highlight has a red for text, and both should be that red.

Trait Implementations§

Source§

impl Clone for Run

Source§

fn clone(&self) -> Self

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§

impl<UT> ConvertError<UT> for Run

Source§

impl Debug for Run

Source§

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

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

impl<UT> FfiConverter<UT> for Run

Source§

const TYPE_ID_META: MetadataBuffer

Type ID metadata, serialized into a MetadataBuffer.
Source§

type FfiType = RustBuffer

The low-level type used for passing values of this type over the FFI. Read more
Source§

fn lower(v: Self) -> RustBuffer

Lower a rust value of the target type, into an FFI value of type Self::FfiType. Read more
Source§

fn try_lift(buf: RustBuffer) -> Result<Self>

Lift a rust value of the target type, from an FFI value of type Self::FfiType. Read more
Source§

fn write(obj: Self, buf: &mut Vec<u8>)

Write a rust value into a buffer, to send over the FFI in serialized form. Read more
Source§

fn try_read(buf: &mut &[u8]) -> Result<Self>

Read a rust value from a buffer, received over the FFI in serialized form. Read more
Source§

impl<UT> Lift<UT> for Run

Source§

type FfiType = <Run as FfiConverter<UT>>::FfiType

Source§

fn try_lift(v: Self::FfiType) -> Result<Self>

Source§

fn try_read(buf: &mut &[u8]) -> Result<Self>

Source§

fn try_lift_from_rust_buffer(v: RustBuffer) -> Result<Self, Error>

Convenience method
Source§

impl<UT> LiftRef<UT> for Run

Source§

impl<UT> LiftReturn<UT> for Run

Source§

type ReturnType = <Run as Lift<UT>>::FfiType

FFI return type for trait interfaces
Source§

fn try_lift_successful_return(v: Self::ReturnType) -> Result<Self>

Lift a successfully returned value from a trait interface
Source§

fn lift_foreign_return( ffi_return: Self::ReturnType, call_status: RustCallStatus, ) -> Self

Lift a foreign returned value from a trait interface Read more
Source§

fn lift_error(_buf: RustBuffer) -> Self

Lift a Rust value for a callback interface method error result Read more
Source§

fn handle_callback_unexpected_error(e: UnexpectedUniFFICallbackError) -> Self

Lift a Rust value for an unexpected callback interface error Read more
Source§

impl<UT> Lower<UT> for Run

Source§

type FfiType = <Run as FfiConverter<UT>>::FfiType

Source§

fn lower(obj: Self) -> Self::FfiType

Source§

fn write(obj: Self, buf: &mut Vec<u8>)

Source§

fn lower_into_rust_buffer(obj: Self) -> RustBuffer

Convenience method
Source§

impl<UT> LowerError<UT> for Run

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for Run

Source§

type ReturnType = <Run as Lower<UT>>::FfiType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return(v: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
Source§

fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
Source§

impl PartialEq for Run

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Run

Source§

impl<UT> TypeId<UT> for Run

Auto Trait Implementations§

§

impl Freeze for Run

§

impl RefUnwindSafe for Run

§

impl Send for Run

§

impl Sync for Run

§

impl Unpin for Run

§

impl UnsafeUnpin for Run

§

impl UnwindSafe for Run

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, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self> ⓘ

Get a clone of the Arc<> using a “borrowed” handle. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.