pub struct BundleStreamWriter<W: Write> { /* private fields */ }Expand description
A streaming v2 bundle writer: writes the MANIFEST up front, then appends members ONE AT A
TIME (append_member), each from a bounded staging
temp the caller may delete the instant the call returns — so the node never holds more
than the largest single member. The export driver drives it from a blocking task, staging
each member just before it appends and deleting the temp just after (see the convenience
wrapper write_bundle_streaming, which encapsulates exactly that produce→append→delete
loop).
Implementations§
Source§impl<W: Write> BundleStreamWriter<W>
impl<W: Write> BundleStreamWriter<W>
Sourcepub fn new(
out: W,
created_at: u64,
data_only: bool,
source: SourceInfo,
specs: Vec<MemberSpec>,
) -> Result<Self, BundleError>
pub fn new( out: W, created_at: u64, data_only: bool, source: SourceInfo, specs: Vec<MemberSpec>, ) -> Result<Self, BundleError>
Begin a streamable bundle on out, writing the MANIFEST (the ordered member list) first.
specs is every member in restore order; each must then be supplied, in that order, via
append_member (Sidecar framing) or
append_member_chunked (ChunkedTrailer framing) to match
the spec’s declared framing, and the bundle closed with finish. The
MANIFEST declares BUNDLE_FORMAT_VERSION_V3 when ANY member is chunked, else
BUNDLE_FORMAT_VERSION_V2 — so a bundle with no chunked member is byte-identical to the
pre-v3 v2 form (an inc1 node can still read it).
Sourcepub fn append_member(
&mut self,
path: &str,
kind: MemberKind,
src: &Path,
) -> Result<(), BundleError>
pub fn append_member( &mut self, path: &str, kind: MemberKind, src: &Path, ) -> Result<(), BundleError>
Append the next member, whose bytes are staged at src (a bounded temp). Writes the
member’s .brmeta sidecar (size + SHA-256, read from src) then the member data,
both streamed from src (never buffered whole). The path/kind MUST match the next
member the MANIFEST declared — an out-of-order or unexpected append is refused loud.
Sourcepub fn append_member_chunked(
&mut self,
path: &str,
kind: MemberKind,
body: &mut dyn Read,
chunk_size: usize,
) -> Result<(), BundleError>
pub fn append_member_chunked( &mut self, path: &str, kind: MemberKind, body: &mut dyn Read, chunk_size: usize, ) -> Result<(), BundleError>
Append the next member as a run of chunk_size-byte .part{N} tar entries followed by a
.brtrailer (MemberTrailer: size + SHA-256). Streams body through, hashing + counting
WHILE writing each chunk — it NEVER stats or buffers the whole member (at most one
chunk_size buffer lives at a time), so a producer that yields a &mut dyn Read over an
engine dump (the libsql .dump stream, pg_dump stdout) is written in O(chunk) disk +
memory. The path/kind MUST match the next declared member AND its framing MUST be
MemberFraming::ChunkedTrailer — an out-of-order, unexpected, or wrong-framing append is
refused loud. chunk_size must be non-zero.
Sourcepub fn finish(self) -> Result<(), BundleError>
pub fn finish(self) -> Result<(), BundleError>
Finish the bundle: refuse if any declared member was never appended, then flush.
Auto Trait Implementations§
impl<W> Freeze for BundleStreamWriter<W>
impl<W> RefUnwindSafe for BundleStreamWriter<W>where
Builder<W>: RefUnwindSafe,
impl<W> Send for BundleStreamWriter<W>
impl<W> Sync for BundleStreamWriter<W>
impl<W> Unpin for BundleStreamWriter<W>
impl<W> UnsafeUnpin for BundleStreamWriter<W>where
Builder<W>: UnsafeUnpin,
impl<W> UnwindSafe for BundleStreamWriter<W>where
Builder<W>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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> ⓘ
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> ⓘ
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