Skip to content

Commit

Permalink
chore: update async-stream-lite
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Dec 4, 2024
1 parent f4ab24e commit 5811901
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ simd-json = { version = "0.13", optional = true }
url = { version = "2.5", optional = true }
rand = { version = "0.8", optional = true }
regex = { version = "1.10", optional = true }
async-stream-lite = "0.1"
async-stream-lite = "0.2"
pin-project-lite = "0.2"

[dev-dependencies]
Expand Down
32 changes: 16 additions & 16 deletions src/youtube/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<'r> IntoIterator for ActionChunk<'r> {
pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action, Error>>, Error> {
let initial_chat = GetLiveChatResponse::fetch(options, &options.initial_continuation).await?;

Ok(Box::pin(try_async_stream(|r#yield| async move {
Ok(Box::pin(try_async_stream(|yielder| async move {
let mut seen_messages = HashSet::new();

match &initial_chat.continuation_contents.as_ref().unwrap().live_chat_continuation.continuations[0] {
Expand All @@ -152,19 +152,19 @@ pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action
match action {
Action::AddChatItem { item, .. } => {
if !seen_messages.contains(item.id()) {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
seen_messages.insert(item.id().to_owned());
}
}
Action::ReplayChat { actions, .. } => {
for action in actions {
if let Action::AddChatItem { .. } = action.action {
r#yield(action.action.to_owned()).await;
yielder.r#yield(action.action.to_owned()).await;
}
}
}
action => {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
}
}
}
Expand All @@ -180,19 +180,19 @@ pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action
match action {
Action::AddChatItem { item, .. } => {
if !seen_messages.contains(item.id()) {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
seen_messages.insert(item.id().to_owned());
}
}
Action::ReplayChat { actions, .. } => {
for action in actions {
if let Action::AddChatItem { .. } = action.action {
r#yield(action.action.to_owned()).await;
yielder.r#yield(action.action.to_owned()).await;
}
}
}
action => {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
}
}
}
Expand Down Expand Up @@ -225,19 +225,19 @@ pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action
match action {
Action::AddChatItem { item, .. } => {
if !seen_messages.contains(item.id()) {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
seen_messages.insert(item.id().to_owned());
}
}
Action::ReplayChat { actions, .. } => {
for action in actions {
if let Action::AddChatItem { .. } = action.action {
r#yield(action.action.to_owned()).await;
yielder.r#yield(action.action.to_owned()).await;
}
}
}
action => {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
}
}
}
Expand All @@ -259,17 +259,17 @@ pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action
for action in chunk.iter() {
match action {
Action::AddChatItem { .. } => {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
}
Action::ReplayChat { actions, .. } => {
for action in actions {
if let Action::AddChatItem { .. } = action.action {
r#yield(action.action.to_owned()).await;
yielder.r#yield(action.action.to_owned()).await;
}
}
}
action => {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
}
}
}
Expand All @@ -287,19 +287,19 @@ pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action
match action {
Action::AddChatItem { item, .. } => {
if !seen_messages.contains(item.id()) {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
seen_messages.insert(item.id().to_owned());
}
}
Action::ReplayChat { actions, .. } => {
for action in actions {
if let Action::AddChatItem { .. } = action.action {
r#yield(action.action.to_owned()).await;
yielder.r#yield(action.action.to_owned()).await;
}
}
}
action => {
r#yield(action.to_owned()).await;
yielder.r#yield(action.to_owned()).await;
}
}
}
Expand Down

0 comments on commit 5811901

Please sign in to comment.