Skip to content

Commit

Permalink
Revert stream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Dec 23, 2024
1 parent 922f810 commit 7953158
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 395 deletions.
4 changes: 3 additions & 1 deletion lib/grammers-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ default = ["fs"]

[dependencies]
chrono = "0.4.38"
futures = "0.3.31"
futures-util = { version = "0.3.30", default-features = false, features = [
"alloc"
] }
grammers-crypto = { path = "../grammers-crypto", version = "0.7.0" }
grammers-mtproto = { path = "../grammers-mtproto", version = "0.7.0" }
grammers-mtsender = { path = "../grammers-mtsender", version = "0.7.0" }
Expand Down
4 changes: 2 additions & 2 deletions lib/grammers-client/DEPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ Used to test that this file lists all dependencies from `Cargo.toml`.
Used for return custom types that `impl Future` so that the requests can be further configured
without having to use `Box`.

## futures
## futures-util

Provides Stream functionality
Provides useful functions for working with futures/tasks.

## url

Expand Down
5 changes: 2 additions & 3 deletions lib/grammers-client/examples/dialogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
//! cargo run --example dialogs
//! ```
use futures::TryStreamExt;
use grammers_client::session::Session;
use grammers_client::{Client, Config, SignInError};
use simple_logger::SimpleLogger;
Expand Down Expand Up @@ -89,10 +88,10 @@ async fn async_main() -> Result<()> {
}
}

let mut dialogs = client.stream_dialogs();
let mut dialogs = client.iter_dialogs();

println!("Showing up to {} dialogs:", dialogs.total().await?);
while let Some(dialog) = dialogs.try_next().await? {
while let Some(dialog) = dialogs.next().await? {
let chat = dialog.chat();
println!("- {: >10} {}", chat.id(), chat.name().unwrap_or_default());
}
Expand Down
5 changes: 2 additions & 3 deletions lib/grammers-client/examples/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use std::io::{BufRead, Write};
use std::path::Path;
use std::{env, io};

use futures::TryStreamExt;
use grammers_client::{Client, Config, SignInError};
use mime::Mime;
use mime_guess::mime;
Expand Down Expand Up @@ -90,7 +89,7 @@ async fn async_main() -> Result<()> {

let chat = maybe_chat.unwrap_or_else(|| panic!("Chat {chat_name} could not be found"));

let mut messages = client.stream_messages(&chat);
let mut messages = client.iter_messages(&chat);

println!(
"Chat {} has {} total messages.",
Expand All @@ -100,7 +99,7 @@ async fn async_main() -> Result<()> {

let mut counter = 0;

while let Some(msg) = messages.try_next().await? {
while let Some(msg) = messages.next().await? {
counter += 1;
println!("Message {}:{}", msg.id(), msg.text());
if let Some(media) = msg.media() {
Expand Down
10 changes: 4 additions & 6 deletions lib/grammers-client/examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
//! cargo run --example echo -- BOT_TOKEN
//! ```
use futures_util::future::{select, Either};
use grammers_client::session::Session;
use grammers_client::{Client, Config, InitParams, Update};
use simple_logger::SimpleLogger;
use std::env;
use std::pin::pin;

use futures::future::{select, Either};
use simple_logger::SimpleLogger;
use tokio::{runtime, task};

use grammers_client::session::Session;
use grammers_client::{Client, Config, InitParams, Update};

type Result = std::result::Result<(), Box<dyn std::error::Error>>;

const SESSION_FILE: &str = "echo.session";
Expand Down
10 changes: 4 additions & 6 deletions lib/grammers-client/examples/inline-pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@
//! how much data a button's payload can contain, and to keep it simple, we're storing it inline
//! in decimal, so the numbers can't get too large).
use futures_util::future::{select, Either};
use grammers_client::session::Session;
use grammers_client::{button, reply_markup, Client, Config, InputMessage, Update};
use simple_logger::SimpleLogger;
use std::env;
use std::pin::pin;

use futures::future::{select, Either};
use simple_logger::SimpleLogger;
use tokio::{runtime, task};

use grammers_client::session::Session;
use grammers_client::{button, reply_markup, Client, Config, InputMessage, Update};

type Result = std::result::Result<(), Box<dyn std::error::Error>>;

const SESSION_FILE: &str = "inline-pagination.session";
Expand Down
Loading

0 comments on commit 7953158

Please sign in to comment.