Skip to main content

RequestExt

Trait RequestExt 

Source
pub trait RequestExt {
    // Required methods
    fn tag(&self) -> Option<&Tag>;
    fn depth(&self) -> Depth;
    fn attempt(&self) -> Attempt;
    fn identity(&self) -> Option<&Identity>;
}
Expand description

Reads crawl metadata from a Request.

A request gets its Tag, Depth and Attempt from the seed it is made from, in Seed::into_request. A request built any other way has no tag, the root depth and the first attempt; to give one metadata, e.g. to test a handler, build it from a seed:

use spire_core::frontier::seed::Seed;
use spire_core::http::RequestExt;
use spire_core::crawler::Tag;

let request = Seed::get("https://example.com/")?.with_tag("page").into_request();
assert_eq!(request.tag(), Some(&Tag::from("page")));

Required Methods§

Source

fn tag(&self) -> Option<&Tag>

Returns the tag, if the request has one.

Source

fn depth(&self) -> Depth

Returns the depth, defaulting to Depth::ROOT.

Source

fn attempt(&self) -> Attempt

Returns the attempt, defaulting to Attempt::FIRST.

Source

fn identity(&self) -> Option<&Identity>

Returns the identity the request goes out as, if the crawl has identities.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<B> RequestExt for Request<B>

Source§

fn tag(&self) -> Option<&Tag>

Source§

fn depth(&self) -> Depth

Source§

fn attempt(&self) -> Attempt

Source§

fn identity(&self) -> Option<&Identity>

Implementors§