Skip to main content

MediaBlock

Struct MediaBlock 

Source
pub struct MediaBlock {
    pub source: MediaSource,
    pub intrinsic: Option<(u32, u32)>,
    pub fit: MediaFit,
    pub alt: String,
    pub height_lh: Option<f32>,
}
Expand description

An inline media block: what to draw, how big, and what to say instead.

Fields§

§source: MediaSource§intrinsic: Option<(u32, u32)>

Natural size in pixels, once a header read has established it. None until then — and a block is perfectly usable meanwhile, which is the point: it reserves rows either way.

§fit: MediaFit§alt: String

What the TUI shows and what a screen reader reads. Never empty in practice — MediaBlock::new falls back to the file name — because a blank box tells the user nothing about what they are missing.

§height_lh: Option<f32>

IM.5: the block’s drawn height in line-heights, once geometry is known — None until then.

This is the number that makes the block genuinely variable-height rather than snapped to whole rows, and it is deliberately allowed to differ from the reserved row count. A 3.4-line-height image reserves 4 rows and draws 3.4 of them.

The HOST populates it, in the media pump’s sizing pass, from the file’s header and the drawing peer’s published cell metrics (inline-media.md §7.1). This comment used to say the renderer did, “through RowWeights” — which was the intent and never the code: no renderer ever wrote it, so it stayed None on every block and the GPUI peer skipped each one as unresolved.

None still means “not measured”, and a peer that draws pixels must treat it that way: on a peer that published no metrics, and for a file whose header could not be read, it stays None and the alt text is the rendering.

Implementations§

Source§

impl MediaBlock

Source

pub fn new(path: impl Into<PathBuf>, alt: Option<String>) -> Self

A block for path, with alt defaulting to the file’s name when the producer has nothing better.

Source

pub fn path(&self) -> Option<&Path>

The path, when the source is one.

Source

pub fn line_heights(&self, rows: u16) -> f32

Height in line-heights — the drawn height once geometry is known, else the reserved row count.

The fallback is what keeps a block harmless before its size is resolved and on any peer that does not draw media: it then costs the scroll walks exactly what its rows already cost, so introducing a block cannot move an existing scroll position.

Trait Implementations§

Source§

impl Clone for MediaBlock

Source§

fn clone(&self) -> MediaBlock

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 Debug for MediaBlock

Source§

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

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

impl PartialEq for MediaBlock

Source§

fn eq(&self, other: &MediaBlock) -> 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 MediaBlock

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more