Skip to content

Commit

Permalink
chore: make stream is send
Browse files Browse the repository at this point in the history
  • Loading branch information
giangndm committed Aug 13, 2024
1 parent ef138b8 commit 71976b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/chat/chat_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use futures::Stream;
use std::pin::Pin;
use std::task::{Context, Poll};

type InterStreamType = Pin<Box<dyn Stream<Item = crate::Result<InterStreamEvent>>>>;
type InterStreamType = Pin<Box<dyn Stream<Item = crate::Result<InterStreamEvent>> + Send>>;

/// ChatStream is a Rust Future Stream that iterates through the events of a chat stream request.
pub struct ChatStream {
Expand All @@ -19,7 +19,7 @@ impl ChatStream {

pub fn from_inter_stream<T>(inter_stream: T) -> Self
where
T: Stream<Item = crate::Result<InterStreamEvent>> + Unpin + 'static,
T: Stream<Item = crate::Result<InterStreamEvent>> + Send + Unpin + 'static,
{
let boxed_stream: InterStreamType = Box::pin(inter_stream);
ChatStream::new(boxed_stream)
Expand Down
4 changes: 2 additions & 2 deletions src/webc/web_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use std::task::{Context, Poll};
pub struct WebStream {
stream_mode: StreamMode,
reqwest_builder: Option<RequestBuilder>,
response_future: Option<Pin<Box<dyn Future<Output = Result<Response, Box<dyn Error>>>>>>,
bytes_stream: Option<Pin<Box<dyn Stream<Item = Result<Bytes, Box<dyn Error>>>>>>,
response_future: Option<Pin<Box<dyn Future<Output = Result<Response, Box<dyn Error>>> + Send>>>,
bytes_stream: Option<Pin<Box<dyn Stream<Item = Result<Bytes, Box<dyn Error>>> + Send>>>,
// If a poll was a partial message, so we kept the previous part
partial_message: Option<String>,
// If a poll retrieved multiple messages, we keep to be sent in next poll
Expand Down

0 comments on commit 71976b7

Please sign in to comment.