pub struct StreamHandler { /* private fields */ }
Expand description
StreamHandler
is a lightweight helper for managing streamed responses.
It provides two main components:
chunk_sender
: An asynchronous channel sender used to forward each received chunk of data to a consumer in real time.abort
: An optional abort flag that can be used to stop an ongoing curl perform operation from another thread.
This struct is typically used in combination with the Collector::Streaming
variant to enable progressive consumption of large or continuous responses
without buffering everything in memory.
Implementations§
Source§impl StreamHandler
impl StreamHandler
Sourcepub fn new() -> (Self, UnboundedReceiver<Vec<u8>>)
pub fn new() -> (Self, UnboundedReceiver<Vec<u8>>)
Creates a new StreamHandler
along with its corresponding receiver.
This convenience method sets up a channel for streaming data,
returning both the StreamHandler
(containing the sender) and
the UnboundedReceiver
for consuming chunks.
§Returns
A tuple of:
StreamHandler
: The handler containing the sender and optional abort flag.UnboundedReceiver<Vec<u8>>
: The receiving end for streamed chunks.
Sourcepub fn with_perform_aborter(self, abort: AbortPerform) -> Self
pub fn with_perform_aborter(self, abort: AbortPerform) -> Self
Associates an abort handle with this StreamHandler
.
AbortPerform
is a shared flag across threads that can be toggled
to true
in order to abort the curl perform operation prematurely.
§Example
use curl_http_client::AbortPerform;
use curl_http_client::StreamHandler;
let (handler, rx) = StreamHandler::new();
let aborter = AbortPerform::new();
let handler = handler.with_perform_aborter(aborter);
Trait Implementations§
Source§impl Clone for StreamHandler
impl Clone for StreamHandler
Source§fn clone(&self) -> StreamHandler
fn clone(&self) -> StreamHandler
Returns a duplicate of the value. Read more
1.0.0 · 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 Freeze for StreamHandler
impl RefUnwindSafe for StreamHandler
impl Send for StreamHandler
impl Sync for StreamHandler
impl Unpin for StreamHandler
impl UnwindSafe for StreamHandler
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