fix: unify stream types with trait object
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -240,7 +240,9 @@ impl AsyncItemService {
|
|||||||
let stream = tokio_stream::wrappers::ReceiverStream::new(rx);
|
let stream = tokio_stream::wrappers::ReceiverStream::new(rx);
|
||||||
|
|
||||||
// If length is specified, we need to limit the stream
|
// If length is specified, we need to limit the stream
|
||||||
let limited_stream = if length > 0 {
|
// Use a trait object to ensure both branches have the same type
|
||||||
|
let limited_stream: std::pin::Pin<Box<dyn tokio_stream::Stream<Item = Result<tokio_util::bytes::Bytes, std::io::Error>> + Send>> =
|
||||||
|
if length > 0 {
|
||||||
// We need to track how many bytes we've sent
|
// We need to track how many bytes we've sent
|
||||||
let mut bytes_sent = 0;
|
let mut bytes_sent = 0;
|
||||||
let limited = stream.take_while(move |result| {
|
let limited = stream.take_while(move |result| {
|
||||||
|
|||||||
Reference in New Issue
Block a user