Skip to content

Commit

Permalink
wip wasm reqwest
Browse files Browse the repository at this point in the history
  • Loading branch information
unneon committed Nov 7, 2019
1 parent 5e202e1 commit adac556
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions unijudge-codeforces/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct CachedAuth {
username: String,
}

#[async_trait]
#[async_trait(?Send)]
impl unijudge::Backend for Codeforces {
type CachedAuth = CachedAuth;
type Contest = Contest;
Expand Down Expand Up @@ -96,7 +96,7 @@ impl unijudge::Backend for Codeforces {
.form(&[("action", "enter"), ("csrf_token", &csrf), ("handleOrEmail", username), ("password", password), ("remember", "on")])
.send()
.await?;
let doc = unijudge::debris::Document::new(&resp.text().await?);
let doc = unijudge::debris::Document::new(resp.text().await?.as_str());
let login_succeeded =
doc.find_all(".lang-chooser a").any(|v| v.attr("href").map(|href| href.string()).ok() == Some(format!("/profile/{}", username)));
let wrong_password_or_handle = doc.find_all(".for__password").count() == 1;
Expand Down
2 changes: 1 addition & 1 deletion unijudge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ hex = "0.4"
html5ever = "0.24"
http = "0.1"
log = "0.4"
reqwest = { git = "https://github.com/seanmonstar/reqwest" }
reqwest = { path = "../../reqwest" }
scraper = { git = "https://github.com/pustaczek/scraper", default-features = false }
selectors = "0.21"
serde = { version = "1.0", features = ["derive"] }
Expand Down
6 changes: 3 additions & 3 deletions unijudge/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub type BoxedContestURL = URL<BoxedContest, !>;
pub type BoxedResource = Resource<BoxedContest, BoxedTask>;
pub type BoxedContestDetails = ContestDetails<BoxedContest>;

#[async_trait]
#[async_trait(?Send)]
impl crate::Backend for (dyn DynamicBackend+'static) {
type CachedAuth = BoxedCachedAuth;
type Contest = BoxedContest;
Expand Down Expand Up @@ -114,7 +114,7 @@ impl crate::Backend for (dyn DynamicBackend+'static) {
}
}

#[async_trait]
#[async_trait(?Send)]
pub trait DynamicBackend: Send+Sync {
fn accepted_domainsx(&self) -> &'static [&'static str];
fn deconstruct_resourcex(&self, domain: &str, segments: &[&str]) -> Result<BoxedResource>;
Expand All @@ -140,7 +140,7 @@ pub trait DynamicBackend: Send+Sync {
fn supports_contestsx(&self) -> bool;
}

#[async_trait]
#[async_trait(?Send)]
impl<T> DynamicBackend for T
where
T: crate::Backend,
Expand Down
2 changes: 1 addition & 1 deletion unijudge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl URL<(), ()> {
}
}

#[async_trait]
#[async_trait(?Send)]
pub trait Backend: Send+Sync+'static {
type CachedAuth: Debug+Send+Sync+'static;
type Contest: Debug+Send+Sync+'static;
Expand Down

0 comments on commit adac556

Please sign in to comment.