generated from OBJNULL/Dockerized-Rust
Compare commits
2 commits
9892b663d2
...
5d5df73b7c
Author | SHA1 | Date | |
---|---|---|---|
5d5df73b7c | |||
80c6b51d01 |
2 changed files with 17 additions and 7 deletions
|
@ -1,8 +1,9 @@
|
||||||
// Libraries
|
// Libraries
|
||||||
mod calculator;
|
mod calculator;
|
||||||
use std::io::Result;
|
mod scraper;
|
||||||
|
|
||||||
use calculator::{CalculationResult, Calculator};
|
use calculator::{CalculationResult, Calculator};
|
||||||
|
use scraper::Scraper;
|
||||||
|
use std::io::Result;
|
||||||
|
|
||||||
// Structures
|
// Structures
|
||||||
pub struct Backend {
|
pub struct Backend {
|
||||||
|
@ -22,11 +23,18 @@ impl Backend {
|
||||||
/// ```rs
|
/// ```rs
|
||||||
/// let backend = Backend::new(true)?;
|
/// let backend = Backend::new(true)?;
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new(fetch: bool) -> Result<Self> {
|
pub async fn new(fetch: bool) -> Result<Self> {
|
||||||
// Did we want to fetch our prices?
|
// Did we want to fetch our prices?
|
||||||
let memberships: Vec<String> = if fetch {
|
let memberships: Vec<String> = if fetch {
|
||||||
// Use Internet to get prices
|
// Getting the URL to scrape from
|
||||||
unimplemented!("TODO: Implement online Membership Price Fetching");
|
let scrape_url =
|
||||||
|
"https://www.washluberepair.com/location/frederick-auto-spa-express-rt-85/";
|
||||||
|
|
||||||
|
// Fetching with our Scraper
|
||||||
|
let scraper = Scraper::new(scrape_url);
|
||||||
|
|
||||||
|
// Scraping
|
||||||
|
scraper.start().await?
|
||||||
} else {
|
} else {
|
||||||
// Manually creating our prices
|
// Manually creating our prices
|
||||||
vec![
|
vec![
|
||||||
|
|
|
@ -5,11 +5,13 @@ mod backend;
|
||||||
use backend::Backend;
|
use backend::Backend;
|
||||||
use std::io::Result;
|
use std::io::Result;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use tokio;
|
||||||
|
|
||||||
// Entry Point
|
// Entry Point
|
||||||
fn main() -> Result<()> {
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
// Creating a Backend
|
// Creating a Backend
|
||||||
let backend = Rc::new(Backend::new(false)?);
|
let backend = Rc::new(Backend::new(true).await?);
|
||||||
|
|
||||||
// Creating a new App
|
// Creating a new App
|
||||||
let app = App::new(Rc::clone(&backend))?;
|
let app = App::new(Rc::clone(&backend))?;
|
||||||
|
|
Loading…
Reference in a new issue