spire-core 0.7.0

Core types and traits for Spire web scraping framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Helpers shared by the frontier's tests.

use crate::frontier::seed::Seed;
use crate::frontier::{Frontier, Pop};

pub(crate) fn seed(path: &str) -> Seed {
    Seed::get(format!("https://example.com/{path}")).unwrap()
}

pub(crate) async fn pop_path<F: Frontier>(frontier: &F) -> Option<String> {
    match frontier.pop().await.unwrap() {
        Pop::Ready(seed) => Some(seed.uri().path().trim_start_matches('/').to_owned()),
        Pop::Wait(_) | Pop::Empty => None,
    }
}