pub struct IndexNowApi { /* private fields */ }Expand description
IndexNow client bound to one website (host) and one IndexNow key.
Create it with IndexNowApi::new, optionally change the endpoint with
set_search_engine or the key file
location with set_key_location, then
call send_urls.
Implementations§
Source§impl IndexNowApi
impl IndexNowApi
Sourcepub fn new<T: ToString, U: ToString>(host: T, key: U) -> IndexNowApi
pub fn new<T: ToString, U: ToString>(host: T, key: U) -> IndexNowApi
Creates a client for host authenticated with key.
host– hostname of the site whose URLs you will submit, e.g.www.example.com.key– your IndexNow key: 8 to 128 characters ofa-z,A-Z,0-9and-. The same key must be served as plain text athttps://<host>/<key>.txt(or at the URL given toset_key_location).
The endpoint defaults to https://api.indexnow.org.
Sourcepub fn set_search_engine<T: ToString>(&mut self, search_engine: T)
pub fn set_search_engine<T: ToString>(&mut self, search_engine: T)
Sets the search engine origin to submit to. Pass the origin without the
/IndexNow path, for example https://www.bing.com or https://yandex.com.
Default: https://api.indexnow.org (shared endpoint that notifies every
participating engine).
Sourcepub fn set_key_location<T: ToString>(&mut self, key_location: T)
pub fn set_key_location<T: ToString>(&mut self, key_location: T)
Sets the keyLocation field: the full URL of your key file when it is
not at the default https://<host>/<key>.txt.
Sourcepub async fn send_urls<T: ToString>(
&self,
urls: Vec<T>,
) -> Result<(), IndexNowError>
pub async fn send_urls<T: ToString>( &self, urls: Vec<T>, ) -> Result<(), IndexNowError>
Submits urls to the search engine as one POST /IndexNow request.
All URLs must belong to host. IndexNow accepts up to 10,000 URLs per
request. Returns Ok(()) when the endpoint answers with HTTP 200 or
202 (accepted, key validation pending), IndexNowError::Status for
any other status and IndexNowError::Connection when the request
could not be sent.