This repository has been archived by the owner on Jul 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Sync and Async Code Re-use
Attempt to abstract sync and async requests by writing an abstraction over the flow of data that encompasses a request. The requests fill out a `RequestData` instance which then gets used as the source of future transformations. The login chain is a prime example of this. We define a series of steps that are expressed as a series of sequences which will finally produce the expected outcome. The Session now produces a `Sequence` implementation which needs to be driven by a client. Unfortunately, due to lack of Async Trait support, the async implementation is not as efficient as it could be. Attempt was made to test the code on nightly, but ran into this bug rust-lang/rust#113108
- Loading branch information
Showing
28 changed files
with
1,277 additions
and
924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,10 @@ | ||
use crate::http; | ||
use crate::http::Request; | ||
use crate::http::{Request, RequestDesc}; | ||
use crate::requests::{CaptchaRequest, Ping}; | ||
|
||
pub fn ping<T: http::ClientSync>(client: &T) -> Result<(), http::Error> { | ||
Ping.execute_sync::<T>(client, &http::DefaultRequestFactory {}) | ||
pub fn ping() -> impl Request { | ||
Ping.to_request() | ||
} | ||
|
||
pub async fn ping_async<T: http::ClientAsync>(client: &T) -> Result<(), http::Error> { | ||
Ping.execute_async::<T>(client, &http::DefaultRequestFactory {}) | ||
.await | ||
} | ||
|
||
pub fn captcha_get<T: http::ClientSync>( | ||
client: &T, | ||
token: &str, | ||
force_web: bool, | ||
) -> Result<String, http::Error> { | ||
CaptchaRequest::new(token, force_web).execute_sync(client, &http::DefaultRequestFactory {}) | ||
} | ||
|
||
pub async fn captcha_get_async<T: http::ClientAsync>( | ||
client: &T, | ||
token: &str, | ||
force_web: bool, | ||
) -> Result<String, http::Error> { | ||
CaptchaRequest::new(token, force_web) | ||
.execute_async(client, &http::DefaultRequestFactory {}) | ||
.await | ||
pub fn captcha_get(token: &str, force_web: bool) -> impl Request { | ||
CaptchaRequest::new(token, force_web).to_request() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
mod client; | ||
mod request_repeater; | ||
mod session; | ||
mod totp; | ||
|
||
pub use client::*; | ||
pub use request_repeater::*; | ||
pub use session::*; | ||
pub use totp::*; |
Oops, something went wrong.