pub struct RobotsBuilder { /* private fields */ }Available on crate feature
builder only.Expand description
The set of formatted user-agent groups that can be written
in the robots.txt compliant format.
Implementations§
Source§impl RobotsBuilder
impl RobotsBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new RobotsBuilder with default settings.
Sourcepub fn header(self, header: &str) -> Self
pub fn header(self, header: &str) -> Self
Adds a global header, usually used for permissions or legal notices.
use robotxt::RobotsBuilder;
let txt = RobotsBuilder::default()
.header("Note: Stop right there!")
.group(["*"], |u| u.disallow("/"))
.group(["foobot"], |u| u.allow("/"));Sourcepub fn group<'a>(
self,
group: impl IntoIterator<Item = &'a str>,
factory: impl FnOnce(GroupBuilder) -> GroupBuilder,
) -> Self
pub fn group<'a>( self, group: impl IntoIterator<Item = &'a str>, factory: impl FnOnce(GroupBuilder) -> GroupBuilder, ) -> Self
Adds a new user-agent group from the provided list of user-agents.
use robotxt::RobotsBuilder;
let txt = RobotsBuilder::default()
.group(["*"], |u| u.disallow("/"))
.group(["foobot"], |u| u.allow("/"));Sourcepub fn sitemap(self, sitemap: Url) -> Self
pub fn sitemap(self, sitemap: Url) -> Self
Adds the Sitemap directive from the URL address.
use url::Url;
use robotxt::RobotsBuilder;
let txt = RobotsBuilder::default()
.sitemap("https://example.com/sitemap_1.xml".try_into().unwrap())
.sitemap("https://example.com/sitemap_1.xml".try_into().unwrap());Adds a global footer, usually used for notices.
use robotxt::RobotsBuilder;
let txt = RobotsBuilder::default()
.group(["*"], |u| u.disallow("/"))
.group(["foobot"], |u| u.allow("/"))
.footer("Note: Have a nice day!");Sourcepub fn parse(&self, user_agent: &str) -> Robots
Available on crate feature parser only.
pub fn parse(&self, user_agent: &str) -> Robots
parser only.Parses the constructed output.
See Robots::from_bytes.
Trait Implementations§
Source§impl Clone for RobotsBuilder
impl Clone for RobotsBuilder
Source§fn clone(&self) -> RobotsBuilder
fn clone(&self) -> RobotsBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RobotsBuilder
impl Debug for RobotsBuilder
Source§impl Default for RobotsBuilder
impl Default for RobotsBuilder
Source§fn default() -> RobotsBuilder
fn default() -> RobotsBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RobotsBuilder
impl RefUnwindSafe for RobotsBuilder
impl Send for RobotsBuilder
impl Sync for RobotsBuilder
impl Unpin for RobotsBuilder
impl UnwindSafe for RobotsBuilder
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