Make the boxed errors Send
[?]
Jan 12, 2022, 8:21 PM
AVLXUT3ROXQ2PLLTB5XHPBY2BI5PQRRFJTG2GGZTL7K4VEZZXF3ACDependencies
- [2]
LPVC545KGet the scraper part of this program working - [3]
RNW6D777Minor tidy - [4]
YCWYAX6KFunctions for scraping names integrated enough to test (they don't work yet) - [5]
PQ4BG3ZJThe web scrape functions - [6]
AV73DYWQInitial functions for using sqlite in async environment - [7]
KUANIPWFAdd function for adding name to database - [8]
C376NCOVPrevent flooding the website (still need to better mimic browser requests) - [*]
HMOBTVJ4Initialize crate and add expected dependencies
Change contents
- edit in src/names_database.rs at line 1
use crate::DynResult; - replacement in src/names_database.rs at line 29
) -> Result<Self, Box<dyn std::error::Error>> {) -> DynResult<Self> { - replacement in src/names_database.rs at line 44
pub async fn add_name(&self,name: String,) -> Result<i64, Box<dyn std::error::Error>> {pub async fn add_name(&self, name: String) -> DynResult<i64> { - replacement in src/names_database.rs at line 67
Ok(Err(e)) => Err(Box::new(e) as Box<dyn std::error::Error>),Ok(Err(e)) => Err(Box::new(e) as crate::DynError), - replacement in src/names_database.rs at line 78
) -> Result<U, Box<dyn std::error::Error>> {) -> DynResult<U> { - edit in src/main.rs at line 8
type DynError = Box<dyn std::error::Error + Send + Sync>;type DynResult<A> = Result<A, DynError>; - replacement in src/main.rs at line 28
async fn main() -> Result<(), Box<dyn std::error::Error>> {async fn main() -> DynResult<()> { - replacement in src/main.rs at line 35
async fn run(&self,db: &AsyncConnection,) -> Result<(), Box<dyn std::error::Error>> {async fn run(&self, db: &AsyncConnection) -> DynResult<()> { - edit in src/gather.rs at line 1
use crate::DynResult; - replacement in src/gather.rs at line 29
let (delay, page) = match fetch.next().await {match fetch.next().await { - replacement in src/gather.rs at line 32
(120, Vec::with_capacity(0))tokio::time::sleep(std::time::Duration::new(120, 0)).await; - replacement in src/gather.rs at line 37
Ok(Some(page)) => (5, page),};for (name, gender) in page {if filter.allow(&gender) {tx.send(name).await.unwrap();Ok(Some(page)) => {let wait =tokio::time::sleep(std::time::Duration::new(5, 0));for (name, gender) in page {if filter.allow(&gender) {tx.send(name).await.unwrap();}}wait.await; - replacement in src/gather.rs at line 47
}tokio::time::sleep(std::time::Duration::new(delay, 0)).await;}; - replacement in src/gather.rs at line 70
async fn next(&mut self,) -> Result<Option<Vec<(String, Gender)>>, Box<dyn std::error::Error>> {async fn next(&mut self) -> DynResult<Option<Vec<(String, Gender)>>> { - replacement in src/gather.rs at line 128
(names, action.map(|url| {if url.starts_with("http") {String::from(url)} else {format!("https://babynames.com{}", url)}}), Some(form))(names,action.map(|url| {if url.starts_with("http") {String::from(url)} else {format!("https://babynames.com{}", url)}}),Some(form),)