pub struct DownloadStream { /* private fields */ }Expand description
A streaming download handle that yields data chunks as they are
reconstructed (mirror data_writer/download_stream.rs).
The reconstruction task is spawned at construction but pauses until
start is called (or the first next /
blocking_next). Data is pulled from the sequential
writer’s internal queue, bypassing the synchronous writer thread.
Each call to next()/blocking_next() returns the next sequential chunk,
or Ok(None) at end-of-stream or cancellation. Any reconstruction error
surfaces on the call that would have returned the next chunk (or on the
final None) via the shared run state.
Implementations§
Source§impl DownloadStream
impl DownloadStream
Sourcepub fn start(&mut self)
pub fn start(&mut self)
Unblocks the reconstruction task so it begins producing data.
If already started, this is a no-op. Called automatically on the first
next / blocking_next. This
method is non-async and does not require a tokio runtime context.
Sourcepub async fn next(&mut self) -> Result<Option<Bytes>, SdxError>
pub async fn next(&mut self) -> Result<Option<Bytes>, SdxError>
Returns the next chunk of downloaded data asynchronously.
Returns Ok(None) when the download is complete or cancelled.
Dropping this future before it completes preserves any pending chunk
for the next call. Use cancel to stop the download.
§Errors
Returns SdxError when a background reconstruction task failed.
Sourcepub fn blocking_next(&mut self) -> Result<Option<Bytes>, SdxError>
pub fn blocking_next(&mut self) -> Result<Option<Bytes>, SdxError>
Returns the next chunk of downloaded data, blocking the current thread until data is available.
Returns Ok(None) when the download is complete or cancelled.
§Runtime requirements
This runs the async next on a dedicated multi-threaded
runtime owned by the client, so it works from plain CLI threads and
from tokio::task::spawn_blocking without panicking (upstream
xet-data panics inside an async runtime via blocking_recv). Calling
it from within an async context is supported but blocks that executor
thread until the next chunk arrives — prefer next
there.
§Errors
Returns SdxError when a background reconstruction task failed.
Sourcepub fn cancel(&mut self)
pub fn cancel(&mut self)
Cancels the in-progress (or not-yet-started) download.
Subsequent calls to next / blocking_next
return Ok(None).
Trait Implementations§
Source§impl Drop for DownloadStream
impl Drop for DownloadStream
Auto Trait Implementations§
impl !RefUnwindSafe for DownloadStream
impl !UnwindSafe for DownloadStream
impl Freeze for DownloadStream
impl Send for DownloadStream
impl Sync for DownloadStream
impl Unpin for DownloadStream
impl UnsafeUnpin for DownloadStream
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
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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