pub struct BlockNoteWriter<'a, W: Write> { /* private fields */ }Expand description
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: Write> BlockNoteWriter<'a, W>
impl<'a, W: Write> BlockNoteWriter<'a, W>
Sourcepub fn new(writer: W) -> Self
pub fn new(writer: W) -> Self
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) -> Self
pub fn with_assets(writer: W, assets: &'a dyn AssetProvider) -> Self
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
Trait Implementations§
Auto Trait Implementations§
impl<'a, W> Freeze for BlockNoteWriter<'a, W>where
W: Freeze,
impl<'a, W> !RefUnwindSafe for BlockNoteWriter<'a, W>
impl<'a, W> Send for BlockNoteWriter<'a, W>where
W: Send,
impl<'a, W> Sync for BlockNoteWriter<'a, W>where
W: Sync,
impl<'a, W> Unpin for BlockNoteWriter<'a, W>where
W: Unpin,
impl<'a, W> UnsafeUnpin for BlockNoteWriter<'a, W>where
W: UnsafeUnpin,
impl<'a, W> !UnwindSafe for BlockNoteWriter<'a, W>
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