pub struct HttpResponseStream { /* private fields */ }Expand description
HTTP 响应流
包装 reqwest Response,提供流式数据读取
Implementations§
Source§impl HttpResponseStream
impl HttpResponseStream
Sourcepub fn new(response: Response, abort_flag: Arc<AtomicBool>) -> Self
pub fn new(response: Response, abort_flag: Arc<AtomicBool>) -> Self
创建新的响应流
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
获取响应状态码
Sourcepub async fn next_event(&mut self) -> Result<Option<StreamEvent>>
pub async fn next_event(&mut self) -> Result<Option<StreamEvent>>
读取下一个事件
Sourcepub async fn collect_text(&mut self) -> Result<String>
pub async fn collect_text(&mut self) -> Result<String>
收集所有文本内容
Sourcepub fn into_sse_stream(self) -> impl Stream<Item = Result<SseEvent>>
pub fn into_sse_stream(self) -> impl Stream<Item = Result<SseEvent>>
创建 SSE 事件流
Auto Trait Implementations§
impl !RefUnwindSafe for HttpResponseStream
impl !UnwindSafe for HttpResponseStream
impl Freeze for HttpResponseStream
impl Send for HttpResponseStream
impl Sync for HttpResponseStream
impl Unpin for HttpResponseStream
impl UnsafeUnpin for HttpResponseStream
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