pub struct BlockNoteWriter<'a, W>where
W: Write,{ /* private fields */ }blocknote only.Expand description
Streaming BlockNote JSON writer. Available when the blocknote feature is enabled.
A streaming BlockNote JSON writer.
Writes JSON tokens directly to the underlying Write as events arrive using docspec-json.
Implements EventSink for integration with the DocSpec pipeline.
Use BlockNoteWriter::with_assets to provide an AssetProvider for resolving
embedded asset images as base64 data URIs.
§Type Parameters
W- Any type implementingWrite
Implementations§
Source§impl<'a, W> BlockNoteWriter<'a, W>where
W: Write,
impl<'a, W> BlockNoteWriter<'a, W>where
W: Write,
Sourcepub fn new(writer: W) -> BlockNoteWriter<'a, W>
pub fn new(writer: W) -> BlockNoteWriter<'a, W>
Creates a new BlockNoteWriter that writes to the given writer.
§Arguments
writer- The underlying writer to emit JSON to
Sourcepub fn with_assets(
writer: W,
assets: &'a dyn AssetProvider,
) -> BlockNoteWriter<'a, W>
pub fn with_assets( writer: W, assets: &'a dyn AssetProvider, ) -> BlockNoteWriter<'a, W>
Creates a new BlockNoteWriter with an AssetProvider for resolving embedded assets.
When an Event::Image with ImageSource::Asset is encountered, the provider is called
to resolve the asset bytes. The bytes are base64-encoded and written as a data URI
(data:{content_type};base64,{encoded}) in the BlockNote JSON url field.
§Arguments
writer- The underlying writer to emit JSON toassets- The asset provider for resolving embedded asset references