Skip to main content

Queue

Struct Queue 

Source
pub struct Queue { /* private fields */ }
Expand description

A cloneable handle for adding seeds to a crawl’s Frontier.

Handlers get a queue bound to the request they handle, so Queue::follow can resolve relative links and derive the depth of the requests it queues.

Implementations§

Source§

impl Queue

Source

pub fn new(frontier: impl Frontier) -> Self

Creates a queue over frontier.

Source

pub fn child_of<B>(&self, request: &Request<B>) -> Self

Returns a queue whose follow treats links as found on request.

Source

pub fn rebase(&self, uri: Uri)

Resolves relative links against uri from now on, e.g. the URI a response was served from after redirects. Clones share the base.

Source

pub async fn push<S>(&self, seed: S) -> Result<Admission>
where S: TryInto<Seed>, S::Error: Into<Error>,

Adds seed as is.

§Errors

Returns an error if seed cannot be converted into a Seed or the frontier fails.

Source

pub async fn follow(&self, link: impl Into<Link>) -> Result<Admission>

Adds a link found on the current request, one level deeper.

The followed request has the link’s tag and priority, or else the seed’s. Tags are not inherited: an untagged link goes to the router’s path routes or fallback, so pagination tags its links explicitly.

The tag is not part of the Fingerprint: with a deduplicating frontier, a URL already followed under one tag is a Duplicate under any other.

Relative hrefs resolve against the page; fragments are dropped. Links that are not http(s) URLs, such as mailto: or malformed ones, are skipped with Admission::Unsupported. Outside a handler, links must be absolute and keep their depth.

§Errors

Returns an error if the frontier fails.

Source

pub async fn follow_all<I>(&self, links: I) -> Result<usize>
where I: IntoIterator<Item: Into<Link>>,

Follows every link, returning how many were queued.

§Errors

Returns an error if the frontier fails.

Source

pub fn size_hint(&self) -> Option<usize>

Returns the number of queued seeds, if known.

Trait Implementations§

Source§

impl Clone for Queue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Queue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Queue

§

impl !UnwindSafe for Queue

§

impl Freeze for Queue

§

impl Send for Queue

§

impl Sync for Queue

§

impl Unpin for Queue

§

impl UnsafeUnpin for Queue

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<W> WorkerExt for W

Source§

fn layer<C, M>(self, middleware: M) -> Layered<M, C>
where C: Send + 'static, Self: Worker<C>, M: Middleware<C>,

Wraps this worker in middleware, which runs before it, and before any middleware added earlier.