pub struct WasmMediaSource { /* private fields */ }Expand description
An async media-block producer over a plugin’s MediaClient.
Implementations§
Source§impl WasmMediaSource
impl WasmMediaSource
pub fn new(client: MediaClient) -> Self
pub fn plugin_id(&self) -> PluginId
Sourcepub async fn media_blocks(
&self,
buffer_id: u64,
path: Option<&Path>,
line_count: u32,
text: String,
) -> Result<Vec<MediaBlockRequest>, String>
pub async fn media_blocks( &self, buffer_id: u64, path: Option<&Path>, line_count: u32, text: String, ) -> Result<Vec<MediaBlockRequest>, String>
Produce a buffer’s media blocks — the async producer the host calls OFF the render path.
Graceful: the outer host error (trap / plugin-gone) and the inner guest
WIT err both collapse to the String the caller logs, and on an Err
the caller keeps the buffer’s PRIOR blocks rather than clearing them. A
transient failure mid-edit must not make every image in the document
blink out.
A block naming a path that does not resolve is DROPPED here with a warning rather than failing the batch — one broken link in an org file should not cost the reader every other image on the page.
Trait Implementations§
Source§impl AsyncMediaSource for WasmMediaSource
impl AsyncMediaSource for WasmMediaSource
Source§fn source_id(&self) -> u64
fn source_id(&self) -> u64
Stable id of the producing plugin — the teardown key. Two producers
with the same id are the same plugin, so a reload replaces rather than
duplicates.
Source§fn produce(
&self,
buffer_id: u64,
path: Option<PathBuf>,
line_count: u32,
text: String,
) -> MediaFuture<'_>
fn produce( &self, buffer_id: u64, path: Option<PathBuf>, line_count: u32, text: String, ) -> MediaFuture<'_>
Produce this buffer’s media blocks off the render path.
text is the buffer’s contents. Passed by value rather than through a
document handle because a media scan reads EVERY line: a handle would
cost one boundary crossing per line, where one copy costs one. The copy
is affordable because this runs on open / edit, not per frame.Source§impl Clone for WasmMediaSource
impl Clone for WasmMediaSource
Source§fn clone(&self) -> WasmMediaSource
fn clone(&self) -> WasmMediaSource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for WasmMediaSource
impl !UnwindSafe for WasmMediaSource
impl Freeze for WasmMediaSource
impl Send for WasmMediaSource
impl Sync for WasmMediaSource
impl Unpin for WasmMediaSource
impl UnsafeUnpin for WasmMediaSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more