pub struct UsptoClient { /* private fields */ }Expand description
A wrapper for reqwest::Client that enables downloading patent XML from the USPTO API.
An API key is required to create a client and make requests to the USPTO API.
Implementations§
Source§impl UsptoClient
impl UsptoClient
Sourcepub fn new(api_key: &str) -> Result<Self, UsptoApiError>
pub fn new(api_key: &str) -> Result<Self, UsptoApiError>
Creates a new UsptoClient with the provided API key.
Returns UsptoApiError if the API key is invalid or the client cannot be built.
§Example
let client = UsptoClient::new("YOUR_API_KEY").unwrap();Sourcepub async fn download_patent_xml(
&self,
patent_number: &str,
) -> Result<String, UsptoApiError>
pub async fn download_patent_xml( &self, patent_number: &str, ) -> Result<String, UsptoApiError>
Downloads the XML for the specified patent_number and returns it if successful.
The patent_number must be a U.S. patent number without the country code or punctuation.
Returns UsptoApiError if the download fails.
Sourcepub async fn download_patent_xml_to_file<T: AsRef<Path>>(
&self,
patent_number: &str,
xml_path: T,
) -> Result<(), UsptoApiError>
pub async fn download_patent_xml_to_file<T: AsRef<Path>>( &self, patent_number: &str, xml_path: T, ) -> Result<(), UsptoApiError>
Downloads the XML for the specified patent_number to xml_path.
The patent_number must be a U.S. patent number without the country code or punctuation.
Returns UsptoApiError if the download fails or the file cannot be written.
Sourcepub async fn download_application_xml(
&self,
application_number: &str,
) -> Result<String, UsptoApiError>
pub async fn download_application_xml( &self, application_number: &str, ) -> Result<String, UsptoApiError>
Downloads the XML for the specified application_number and returns it if successful.
The application_number must be a U.S. application number (not publication number) without
punctuation.
Returns UsptoApiError if the download fails.
Sourcepub async fn download_application_xml_to_file<T: AsRef<Path>>(
&self,
application_number: &str,
xml_path: T,
) -> Result<(), UsptoApiError>
pub async fn download_application_xml_to_file<T: AsRef<Path>>( &self, application_number: &str, xml_path: T, ) -> Result<(), UsptoApiError>
Downloads the XML for the specified application_number to xml_path.
The application_number must be a U.S. application number (not publication number) without
punctuation.
Returns UsptoApiError if the download fails or the file cannot be written.