diff --git a/CHANGELOG.md b/CHANGELOG.md index 8336e93..75a7562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog for egg-mode +## [0.14.0] - Unreleased + +### Changed +- Updated to use `std::future::Future`,`async/await`. + - This is a very **breaking change** + - Lots of dependencies updated, most notably `tokio 0.2` and `hyper 0.13` + - Thanks to @bobtwinkles for the implementation +- Various internal refactorings and simplifications + ## [0.13.0] - 2019-06-16 ### Added diff --git a/Cargo.toml b/Cargo.toml index 8a8621b..9b91195 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "egg-mode" -version = "0.13.0" +version = "0.14.0" authors = ["QuietMisdreavus ", "Alex Whitney "] description = "Library to interact with the Twitter API" documentation = "https://tonberry.quietmisdreavus.net/doc/egg_mode/" @@ -15,23 +15,23 @@ edition = "2018" # TODO add badge once https://github.com/rust-lang/crates.io/pull/1838 is merged [dependencies] -base64 = "0.11.0" -chrono = { version = "0.4.10", features = ["serde"] } +base64 = "0.11" +chrono = { version = "0.4", features = ["serde"] } futures = "0.3" -derive_more = "0.99.2" -hmac = "0.7.1" -hyper = "0.13.1" -hyper-rustls = { version = "0.19.0", optional = true } -hyper-tls = { version = "0.4.0", optional = true } -lazy_static = "1.4.0" -native-tls = { version = "0.2.3", optional = true } -mime = "0.3.16" -percent-encoding = "2.1.0" -rand = "0.7.2" -regex = "1.3.1" -serde = { version = "1.0.104", features = ["derive"] } -serde_json = "1.0.44" -sha-1 = "0.8.2" +derive_more = "0.99" +hmac = "0.7" +hyper = "0.13" +hyper-rustls = { version = "0.19", optional = true } +hyper-tls = { version = "0.4", optional = true } +lazy_static = "1.4" +native-tls = { version = "0.2", optional = true } +mime = "0.3" +percent-encoding = "2.1" +rand = "0.7" +regex = "1.3" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +sha-1 = "0.8" tokio = { version = "0.2.8", features = ["time", "rt-core", "macros"] } url = "2.1.1" diff --git a/README.md b/README.md index 7b356a0..476c939 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # egg-mode -Twitter library for rust ![Build Status](https://github.com/QuietMisdreavus/twitter-rs/workflows/CI/badge.svg) +Twitter library for Rust ![Build Status](https://github.com/QuietMisdreavus/twitter-rs/workflows/CI/badge.svg) -[v0.13.0 Documentation](https://tonberry.quietmisdreavus.net/doc/egg_mode/) +[v0.14.0 Documentation](https://tonberry.quietmisdreavus.net/doc/egg_mode/) This is a library for interacting with Twitter from Rust. You can see how much of the Public API is available in the file [TODO.md]. In addition to eventually implementing the entire Public API, an @@ -11,6 +11,8 @@ interact with the Twitter API. Parts of this library are added as a convenience mechanisms; for example, cursored lists of users and tweets can be used as an iterator in addition to being able to manually load a page at a time. +From `v0.14`, egg-mode uses the `async/await` syntax and therefore requires Rust **v1.39.0+**. + [TODO.md]: https://github.com/QuietMisdreavus/twitter-rs/blob/master/TODO.md **NOTE**: Previous versions of egg-mode contained a port of twitter-text to use for character @@ -19,21 +21,19 @@ counting and mention/hashtag/url extraction. That has since been extracted into [egg-mode-text]: https://github.com/QuietMisdreavus/twitter-text-rs -Compatibility note: egg-mode is tested to run on Rust 1.27.0 and later. On Windows, both the -msvc -and -gnu environments are tested. To start using this library, put the following into your Cargo.toml: ```TOML [dependencies] -egg-mode = "0.13.0" +egg-mode = "0.14.0" ``` By default, `egg-mode` uses `native-tls` for encryption, but also supports `rustls`. This may be helpful if you wish to avoid linking against `OpenSSL`. To enable, modify your `Cargo.toml` entry: ``` -egg-mode = { version = "0.13", features = ["hyper-rustls"], default-features = false }` +egg-mode = { version = "0.14", features = ["hyper-rustls"], default-features = false }` ``` See available methods and tips to get started in the [Documentation][]. @@ -41,11 +41,11 @@ See available methods and tips to get started in the [Documentation][]. To authenticate a user and request an access token: ```rust -// NOTE: this assumes you have a Tokio `core` and its `handle` sitting around already +// NOTE: this assumes you are running inside an `async` function let con_token = egg_mode::KeyPair::new("consumer key", "consumer secret"); // "oob" is needed for PIN-based auth; see docs for `request_token` for more info -let request_token = core.run(egg_mode::request_token(&con_token, "oob", &handle)).unwrap(); +let request_token = egg_mode::request_token(&con_token, "oob").await.unwrap(); let auth_url = egg_mode::authorize_url(&request_token); // give auth_url to the user, they can sign in to Twitter and accept your app's permissions. @@ -55,7 +55,7 @@ let verifier = "123456"; //read the PIN from the user here // note this consumes con_token; if you want to sign in multiple accounts, clone it here let (token, user_id, screen_name) = - core.run(egg_mode::access_token(con_token, &request_token, verifier, &handle)).unwrap(); + egg_mode::access_token(con_token, &request_token, verifier).await.unwrap() // token can be given to any egg_mode method that asks for a token // user_id and screen_name refer to the user who signed in @@ -67,9 +67,7 @@ with your application. With this access token, all of the other Twitter function With this token in hand, you can get a user's profile information like this: ```rust -// NOTE: as above, this assumes you have the Tokio `core` and `handle` available - -let rustlang = core.run(egg_mode::user::show("rustlang", &token, &handle)).unwrap(); +let rustlang = egg_mode::user::show("rustlang", &token).await.unwrap(); println!("{} (@{})", rustlang.name, rustlang.screen_name); ```