pub struct RobotsTxtCache { /* private fields */ }Expand description
Per-domain robots.txt cache.
Thread-safe. Fetches robots.txt once per unique domain, parses it, and caches the rules. Subsequent requests for the same domain return the cached result.
Implementations§
Source§impl RobotsTxtCache
impl RobotsTxtCache
Sourcepub fn new(client: Arc<HttpClient>, config: &CrawlConfig) -> Self
pub fn new(client: Arc<HttpClient>, config: &CrawlConfig) -> Self
Create a new cache with the given HTTP client.
Sourcepub async fn get(
&self,
scheme: &str,
domain: &str,
) -> (Vec<RobotsRule>, Vec<String>, String)
pub async fn get( &self, scheme: &str, domain: &str, ) -> (Vec<RobotsRule>, Vec<String>, String)
Get robots.txt rules for a domain.
Returns (rules, sitemap_urls, raw_content). If the domain has
no robots.txt, returns empty vectors and an empty string.
Fetches from the network on first access for each domain.
Sourcepub async fn is_disallowed(
&self,
scheme: &str,
domain: &str,
path: &str,
) -> bool
pub async fn is_disallowed( &self, scheme: &str, domain: &str, path: &str, ) -> bool
Check if a path is disallowed for the given domain and user-agent.
Sourcepub async fn crawl_delay(&self, scheme: &str, domain: &str) -> Option<f64>
pub async fn crawl_delay(&self, scheme: &str, domain: &str) -> Option<f64>
Get crawl-delay for a domain (in seconds).
Sourcepub async fn sitemaps(&self, scheme: &str, domain: &str) -> Vec<String>
pub async fn sitemaps(&self, scheme: &str, domain: &str) -> Vec<String>
Get all sitemap URLs discovered from robots.txt for a domain.
Sourcepub async fn raw_content(&self, scheme: &str, domain: &str) -> String
pub async fn raw_content(&self, scheme: &str, domain: &str) -> String
Get the raw robots.txt content for a domain.
Auto Trait Implementations§
impl !RefUnwindSafe for RobotsTxtCache
impl !UnwindSafe for RobotsTxtCache
impl Freeze for RobotsTxtCache
impl Send for RobotsTxtCache
impl Sync for RobotsTxtCache
impl Unpin for RobotsTxtCache
impl UnsafeUnpin for RobotsTxtCache
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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