pub struct UrlQueue { /* private fields */ }Expand description
Priority URL queue with deduplication and scope control.
Binary heap-based priority queue that ensures URLs are crawled in priority order. Automatically deduplicates URLs and enforces scope control (allowed/blocked domains and paths).
§Examples
use crawlkit_engine::queue::{UrlQueue, ScopeConfig, Priority};
use url::Url;
let queue = UrlQueue::new(ScopeConfig::default());
let url = Url::parse("https://example.com").unwrap();
queue.push(url, 0, Priority::HIGH);
assert_eq!(queue.len(), 1);Implementations§
Source§impl UrlQueue
impl UrlQueue
Sourcepub fn new(scope: ScopeConfig) -> Self
pub fn new(scope: ScopeConfig) -> Self
Creates a new empty queue with the given scope configuration.
Sourcepub fn from_crawl_config(config: &CrawlConfig) -> Self
pub fn from_crawl_config(config: &CrawlConfig) -> Self
Creates a queue from a CrawlConfig.
Sourcepub fn push(&self, url: Url, depth: usize, priority: Priority) -> bool
pub fn push(&self, url: Url, depth: usize, priority: Priority) -> bool
Pushes a URL into the queue with the given depth and priority.
Returns true if the URL was added, false if it was a duplicate
or rejected by scope control.
Sourcepub fn push_with_referrer(
&self,
url: Url,
depth: usize,
priority: Priority,
referrer: Option<Url>,
) -> bool
pub fn push_with_referrer( &self, url: Url, depth: usize, priority: Priority, referrer: Option<Url>, ) -> bool
Pushes a URL with an optional referrer.
Performs deduplication, depth check, and scope filtering.
Sourcepub fn pop(&self) -> Option<QueueEntry>
pub fn pop(&self) -> Option<QueueEntry>
Pops the highest-priority entry from the queue.
Sourcepub fn seen_count(&self) -> usize
pub fn seen_count(&self) -> usize
Returns the number of unique URLs seen (including popped ones).
Sourcepub fn domain_count(&self, domain: &str) -> usize
pub fn domain_count(&self, domain: &str) -> usize
Returns the number of URLs discovered for a given domain.
Sourcepub fn peek(&self) -> Option<QueueEntry>
pub fn peek(&self) -> Option<QueueEntry>
Peeks at the highest-priority entry without removing it.
Sourcepub fn drain(&self) -> Vec<QueueEntry>
pub fn drain(&self) -> Vec<QueueEntry>
Drains all entries from the queue.
Auto Trait Implementations§
impl !Freeze for UrlQueue
impl !RefUnwindSafe for UrlQueue
impl Send for UrlQueue
impl Sync for UrlQueue
impl Unpin for UrlQueue
impl UnsafeUnpin for UrlQueue
impl UnwindSafe for UrlQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more