pub struct FigshareClient { /* private fields */ }Expand description
Typed async client for the core Figshare REST API.
Implementations§
Sourcepub fn builder(auth: Auth) -> FigshareClientBuilder
pub fn builder(auth: Auth) -> FigshareClientBuilder
Starts building a new client from authentication settings.
Sourcepub fn new(auth: Auth) -> Result<Self, FigshareError>
pub fn new(auth: Auth) -> Result<Self, FigshareError>
Builds a client with default endpoint and polling options.
§Errors
Returns an error if the underlying HTTP client cannot be initialized.
Sourcepub fn with_token(token: impl Into<String>) -> Result<Self, FigshareError>
pub fn with_token(token: impl Into<String>) -> Result<Self, FigshareError>
Builds a client directly from a raw API token.
§Errors
Returns an error if the underlying HTTP client cannot be initialized.
Sourcepub fn anonymous() -> Result<Self, FigshareError>
pub fn anonymous() -> Result<Self, FigshareError>
Builds an anonymous client for public API calls.
§Errors
Returns an error if the underlying HTTP client cannot be initialized.
Sourcepub fn from_env() -> Result<Self, FigshareError>
pub fn from_env() -> Result<Self, FigshareError>
Builds a client from Auth::TOKEN_ENV_VAR.
§Errors
Returns an error if the environment variable is missing or invalid, or if the underlying HTTP client cannot be initialized.
Sourcepub fn poll_options(&self) -> &PollOptions
pub fn poll_options(&self) -> &PollOptions
Returns the configured polling behavior.
Sourcepub fn request_timeout(&self) -> Option<Duration>
pub fn request_timeout(&self) -> Option<Duration>
Returns the configured overall HTTP request timeout.
Sourcepub fn connect_timeout(&self) -> Option<Duration>
pub fn connect_timeout(&self) -> Option<Duration>
Returns the configured TCP connect timeout.
Sourcepub async fn list_licenses(&self) -> Result<Vec<ArticleLicense>, FigshareError>
pub async fn list_licenses(&self) -> Result<Vec<ArticleLicense>, FigshareError>
Lists public licenses.
§Errors
Returns an error if the request fails or Figshare returns a non-success response.
Sourcepub async fn list_categories(
&self,
) -> Result<Vec<ArticleCategory>, FigshareError>
pub async fn list_categories( &self, ) -> Result<Vec<ArticleCategory>, FigshareError>
Lists public categories.
§Errors
Returns an error if the request fails or Figshare returns a non-success response.
Sourcepub async fn list_account_categories(
&self,
) -> Result<Vec<ArticleCategory>, FigshareError>
pub async fn list_account_categories( &self, ) -> Result<Vec<ArticleCategory>, FigshareError>
Lists categories available to the authenticated account.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn list_public_articles(
&self,
query: &ArticleQuery,
) -> Result<Vec<Article>, FigshareError>
pub async fn list_public_articles( &self, query: &ArticleQuery, ) -> Result<Vec<Article>, FigshareError>
Lists public articles.
§Errors
Returns an error if the request fails or Figshare returns a non-success response.
Sourcepub async fn list_public_article_versions(
&self,
id: ArticleId,
) -> Result<Vec<ArticleVersion>, FigshareError>
pub async fn list_public_article_versions( &self, id: ArticleId, ) -> Result<Vec<ArticleVersion>, FigshareError>
Lists public versions for one article.
§Errors
Returns an error if the request fails or Figshare returns a non-success response.
Sourcepub async fn get_public_article_version(
&self,
id: ArticleId,
version: u64,
) -> Result<Article, FigshareError>
pub async fn get_public_article_version( &self, id: ArticleId, version: u64, ) -> Result<Article, FigshareError>
Reads one specific public article version.
§Errors
Returns an error if the request fails or Figshare returns a non-success response.
Sourcepub async fn list_own_articles(
&self,
query: &ArticleQuery,
) -> Result<Vec<Article>, FigshareError>
pub async fn list_own_articles( &self, query: &ArticleQuery, ) -> Result<Vec<Article>, FigshareError>
Lists the authenticated account’s own articles.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn search_own_articles(
&self,
query: &ArticleQuery,
) -> Result<Vec<Article>, FigshareError>
pub async fn search_own_articles( &self, query: &ArticleQuery, ) -> Result<Vec<Article>, FigshareError>
Searches the authenticated account’s own articles.
§Errors
Returns an error if authentication is missing, if the query is invalid, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn get_own_article(
&self,
id: ArticleId,
) -> Result<Article, FigshareError>
pub async fn get_own_article( &self, id: ArticleId, ) -> Result<Article, FigshareError>
Reads one private article owned by the authenticated account.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn delete_article(&self, id: ArticleId) -> Result<(), FigshareError>
pub async fn delete_article(&self, id: ArticleId) -> Result<(), FigshareError>
Deletes a private article.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn reserve_doi(&self, id: ArticleId) -> Result<Doi, FigshareError>
pub async fn reserve_doi(&self, id: ArticleId) -> Result<Doi, FigshareError>
Reserves a DOI for a private article.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn list_files(
&self,
id: ArticleId,
) -> Result<Vec<ArticleFile>, FigshareError>
pub async fn list_files( &self, id: ArticleId, ) -> Result<Vec<ArticleFile>, FigshareError>
Lists files attached to a private article.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn list_public_article_version_files(
&self,
article_id: ArticleId,
version: u64,
) -> Result<Vec<ArticleFile>, FigshareError>
pub async fn list_public_article_version_files( &self, article_id: ArticleId, version: u64, ) -> Result<Vec<ArticleFile>, FigshareError>
Lists files attached to one public article version.
§Errors
Returns an error if the request fails or if Figshare returns a non-success response.
Sourcepub async fn get_file(
&self,
article_id: ArticleId,
file_id: FileId,
) -> Result<ArticleFile, FigshareError>
pub async fn get_file( &self, article_id: ArticleId, file_id: FileId, ) -> Result<ArticleFile, FigshareError>
Reads one file attached to a private article.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn delete_file(
&self,
article_id: ArticleId,
file_id: FileId,
) -> Result<(), FigshareError>
pub async fn delete_file( &self, article_id: ArticleId, file_id: FileId, ) -> Result<(), FigshareError>
Deletes a file from a private article.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn initiate_file_upload(
&self,
article_id: ArticleId,
name: &str,
size: u64,
md5: &str,
) -> Result<ArticleFile, FigshareError>
pub async fn initiate_file_upload( &self, article_id: ArticleId, name: &str, size: u64, md5: &str, ) -> Result<ArticleFile, FigshareError>
Initiates a hosted file upload for a private article.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn initiate_link_file(
&self,
article_id: ArticleId,
link: &str,
) -> Result<ArticleFile, FigshareError>
pub async fn initiate_link_file( &self, article_id: ArticleId, link: &str, ) -> Result<ArticleFile, FigshareError>
Initiates a link-only file attachment for a private article.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn get_upload_session(
&self,
upload_url: &Url,
) -> Result<UploadSession, FigshareError>
pub async fn get_upload_session( &self, upload_url: &Url, ) -> Result<UploadSession, FigshareError>
Reads one upload session from the upload service.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn upload_part(
&self,
upload_url: &Url,
part_no: u64,
bytes: Vec<u8>,
) -> Result<(), FigshareError>
pub async fn upload_part( &self, upload_url: &Url, part_no: u64, bytes: Vec<u8>, ) -> Result<(), FigshareError>
Uploads one part to the upload service.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn reset_upload_part(
&self,
upload_url: &Url,
part_no: u64,
) -> Result<(), FigshareError>
pub async fn reset_upload_part( &self, upload_url: &Url, part_no: u64, ) -> Result<(), FigshareError>
Resets one uploaded part.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn complete_file_upload(
&self,
article_id: ArticleId,
file_id: FileId,
) -> Result<(), FigshareError>
pub async fn complete_file_upload( &self, article_id: ArticleId, file_id: FileId, ) -> Result<(), FigshareError>
Marks an uploaded file as complete.
§Errors
Returns an error if authentication is missing, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn upload_path(
&self,
article_id: ArticleId,
path: &Path,
) -> Result<ArticleFile, FigshareError>
pub async fn upload_path( &self, article_id: ArticleId, path: &Path, ) -> Result<ArticleFile, FigshareError>
Uploads a local file path to a private article.
§Errors
Returns an error if authentication is missing, if the local file cannot be read, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn upload_reader<R>(
&self,
article_id: ArticleId,
filename: &str,
reader: R,
content_length: u64,
) -> Result<ArticleFile, FigshareError>
pub async fn upload_reader<R>( &self, article_id: ArticleId, filename: &str, reader: R, content_length: u64, ) -> Result<ArticleFile, FigshareError>
Uploads data from a blocking reader by staging it to a temporary file and performing a standard Figshare hosted upload.
§Errors
Returns an error if authentication is missing, if staging the reader fails, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn open_public_article_file_by_name(
&self,
article_id: ArticleId,
name: &str,
latest: bool,
) -> Result<DownloadStream, FigshareError>
pub async fn open_public_article_file_by_name( &self, article_id: ArticleId, name: &str, latest: bool, ) -> Result<DownloadStream, FigshareError>
Opens a file from a public article by exact file name.
When latest is true, the latest public article version is resolved
before selecting the file.
§Errors
Returns an error if the article or file cannot be resolved, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn open_article_file_by_doi(
&self,
doi: &Doi,
name: &str,
latest: bool,
) -> Result<DownloadStream, FigshareError>
pub async fn open_article_file_by_doi( &self, doi: &Doi, name: &str, latest: bool, ) -> Result<DownloadStream, FigshareError>
Opens a file from a public article selected by DOI.
When latest is true, the latest public article version is resolved
before selecting the file.
§Errors
Returns an error if the article or file cannot be resolved, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn open_own_article_file_by_name(
&self,
article_id: ArticleId,
name: &str,
) -> Result<DownloadStream, FigshareError>
pub async fn open_own_article_file_by_name( &self, article_id: ArticleId, name: &str, ) -> Result<DownloadStream, FigshareError>
Opens a file from one of the authenticated account’s own articles by exact file name.
§Errors
Returns an error if authentication is missing, if the article or file cannot be resolved, if the request fails, or if Figshare returns a non-success response.
Sourcepub async fn download_public_article_file_by_name_to_path(
&self,
article_id: ArticleId,
name: &str,
latest: bool,
path: &Path,
) -> Result<ResolvedDownload, FigshareError>
pub async fn download_public_article_file_by_name_to_path( &self, article_id: ArticleId, name: &str, latest: bool, path: &Path, ) -> Result<ResolvedDownload, FigshareError>
Downloads a file from a public article by exact file name.
§Errors
Returns an error if the article or file cannot be resolved, if the request fails, or if writing the destination path fails.
Sourcepub async fn download_article_file_by_doi_to_path(
&self,
doi: &Doi,
name: &str,
latest: bool,
path: &Path,
) -> Result<ResolvedDownload, FigshareError>
pub async fn download_article_file_by_doi_to_path( &self, doi: &Doi, name: &str, latest: bool, path: &Path, ) -> Result<ResolvedDownload, FigshareError>
Downloads a file from a public article resolved by DOI.
§Errors
Returns an error if the article or file cannot be resolved, if the request fails, or if writing the destination path fails.
Sourcepub async fn download_own_article_file_by_name_to_path(
&self,
article_id: ArticleId,
name: &str,
path: &Path,
) -> Result<ResolvedDownload, FigshareError>
pub async fn download_own_article_file_by_name_to_path( &self, article_id: ArticleId, name: &str, path: &Path, ) -> Result<ResolvedDownload, FigshareError>
Downloads a file from one of the authenticated account’s own articles by exact file name.
§Errors
Returns an error if authentication is missing, if the article or file cannot be resolved, if the request fails, or if writing the destination path fails.
Trait Implementations§
Source§type PollOptions = PollOptions
type PollOptions = PollOptions
Source§type Error = FigshareError
type Error = FigshareError
Source§fn poll_options(&self) -> &Self::PollOptions
fn poll_options(&self) -> &Self::PollOptions
Source§fn request_timeout(&self) -> Option<Duration>
fn request_timeout(&self) -> Option<Duration>
Source§fn connect_timeout(&self) -> Option<Duration>
fn connect_timeout(&self) -> Option<Duration>
Source§fn clone(&self) -> FigshareClient
fn clone(&self) -> FigshareClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more