pub struct ZenodoClient { /* private fields */ }Expand description
Typed async client for the core Zenodo REST API.
Implementations§
Source§impl ZenodoClient
impl ZenodoClient
Sourcepub fn builder(auth: Auth) -> ZenodoClientBuilder
pub fn builder(auth: Auth) -> ZenodoClientBuilder
Starts building a new client from authentication settings.
§Examples
use zenodo_rs::{Auth, Endpoint, ZenodoClient};
let client = ZenodoClient::builder(Auth::new("token"))
.sandbox()
.build()?;
assert!(matches!(client.endpoint(), Endpoint::Sandbox));Sourcepub fn new(auth: Auth) -> Result<Self, ZenodoError>
pub fn new(auth: Auth) -> Result<Self, ZenodoError>
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, ZenodoError>
pub fn with_token(token: impl Into<String>) -> Result<Self, ZenodoError>
Sourcepub fn from_env() -> Result<Self, ZenodoError>
pub fn from_env() -> Result<Self, ZenodoError>
Builds a production 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 from_sandbox_env() -> Result<Self, ZenodoError>
pub fn from_sandbox_env() -> Result<Self, ZenodoError>
Builds a sandbox client from Auth::SANDBOX_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 create_deposition(&self) -> Result<Deposition, ZenodoError>
pub async fn create_deposition(&self) -> Result<Deposition, ZenodoError>
Creates a new empty deposition draft.
§Errors
Returns an error if the request fails or Zenodo returns a non-success response.
Sourcepub async fn get_deposition(
&self,
id: DepositionId,
) -> Result<Deposition, ZenodoError>
pub async fn get_deposition( &self, id: DepositionId, ) -> Result<Deposition, ZenodoError>
Fetches a single deposition by deposition ID.
§Errors
Returns an error if the request fails or Zenodo returns a non-success response.
Sourcepub async fn update_metadata(
&self,
id: DepositionId,
metadata: &DepositMetadataUpdate,
) -> Result<Deposition, ZenodoError>
pub async fn update_metadata( &self, id: DepositionId, metadata: &DepositMetadataUpdate, ) -> Result<Deposition, ZenodoError>
Replaces the draft metadata for a deposition.
§Errors
Returns an error if the request fails or Zenodo rejects the metadata.
Sourcepub async fn list_files(
&self,
id: DepositionId,
) -> Result<Vec<DepositionFile>, ZenodoError>
pub async fn list_files( &self, id: DepositionId, ) -> Result<Vec<DepositionFile>, ZenodoError>
Lists the files currently attached to a draft deposition.
§Errors
Returns an error if the request fails or Zenodo returns a non-success response.
Sourcepub async fn delete_file(
&self,
id: DepositionId,
file_id: DepositionFileId,
) -> Result<(), ZenodoError>
pub async fn delete_file( &self, id: DepositionId, file_id: DepositionFileId, ) -> Result<(), ZenodoError>
Deletes a file from a draft deposition.
§Errors
Returns an error if the request fails or Zenodo rejects the delete.
Sourcepub async fn upload_path(
&self,
bucket: &BucketUrl,
filename: &str,
path: &Path,
) -> Result<BucketObject, ZenodoError>
pub async fn upload_path( &self, bucket: &BucketUrl, filename: &str, path: &Path, ) -> Result<BucketObject, ZenodoError>
Uploads a local file to a Zenodo bucket using a fixed content length.
§Errors
Returns an error if the local file cannot be read, if the upload URL cannot be formed, or if Zenodo rejects the upload.
Sourcepub async fn upload_path_with_progress<P>(
&self,
bucket: &BucketUrl,
filename: &str,
path: &Path,
progress: P,
) -> Result<BucketObject, ZenodoError>where
P: TransferProgress + 'static,
pub async fn upload_path_with_progress<P>(
&self,
bucket: &BucketUrl,
filename: &str,
path: &Path,
progress: P,
) -> Result<BucketObject, ZenodoError>where
P: TransferProgress + 'static,
Uploads a local file to a Zenodo bucket while reporting progress.
The supplied progress sink receives the fixed upload size before the
transfer starts and one advance event per streamed chunk.
§Errors
Returns an error if the local file cannot be read, if the upload URL cannot be formed, or if Zenodo rejects the upload.
Sourcepub async fn upload_reader<R>(
&self,
bucket: &BucketUrl,
filename: &str,
reader: R,
content_length: u64,
content_type: Mime,
) -> Result<BucketObject, ZenodoError>
pub async fn upload_reader<R>( &self, bucket: &BucketUrl, filename: &str, reader: R, content_length: u64, content_type: Mime, ) -> Result<BucketObject, ZenodoError>
Uploads data from a blocking reader to a Zenodo bucket.
The caller must provide the exact content length.
§Errors
Returns an error if the upload URL cannot be formed, if the reader fails, or if Zenodo rejects the upload.
Sourcepub async fn upload_reader_with_progress<R, P>(
&self,
bucket: &BucketUrl,
filename: &str,
reader: R,
content_length: u64,
content_type: Mime,
progress: P,
) -> Result<BucketObject, ZenodoError>
pub async fn upload_reader_with_progress<R, P>( &self, bucket: &BucketUrl, filename: &str, reader: R, content_length: u64, content_type: Mime, progress: P, ) -> Result<BucketObject, ZenodoError>
Uploads data from a blocking reader to a Zenodo bucket while reporting progress.
The caller must provide the exact content length. The supplied progress
sink receives the fixed upload size before the transfer starts and one
advance event per chunk that is accepted by the request body stream.
§Errors
Returns an error if the upload URL cannot be formed, if the reader fails, or if Zenodo rejects the upload.
Sourcepub async fn publish(&self, id: DepositionId) -> Result<Deposition, ZenodoError>
pub async fn publish(&self, id: DepositionId) -> Result<Deposition, ZenodoError>
Publishes a draft deposition.
§Errors
Returns an error if the request fails or Zenodo rejects the publish action.
Sourcepub async fn edit(&self, id: DepositionId) -> Result<Deposition, ZenodoError>
pub async fn edit(&self, id: DepositionId) -> Result<Deposition, ZenodoError>
Enters edit mode for a published deposition draft.
§Errors
Returns an error if the request fails or Zenodo rejects the edit action.
Sourcepub async fn discard(&self, id: DepositionId) -> Result<Deposition, ZenodoError>
pub async fn discard(&self, id: DepositionId) -> Result<Deposition, ZenodoError>
Discards the current draft changes for a deposition.
§Errors
Returns an error if the request fails or Zenodo rejects the discard action.
Sourcepub async fn new_version(
&self,
id: DepositionId,
) -> Result<Deposition, ZenodoError>
pub async fn new_version( &self, id: DepositionId, ) -> Result<Deposition, ZenodoError>
Creates a new draft version from a published deposition.
§Errors
Returns an error if the request fails or Zenodo rejects the versioning action.
Source§impl ZenodoClient
impl ZenodoClient
Sourcepub async fn open_artifact(
&self,
selector: &ArtifactSelector,
) -> Result<DownloadStream, ZenodoError>
pub async fn open_artifact( &self, selector: &ArtifactSelector, ) -> Result<DownloadStream, ZenodoError>
Opens a download stream for a Zenodo artifact selector.
§Examples
use zenodo_rs::{ArtifactSelector, Auth, RecordId, ZenodoClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let stream = client
.open_artifact(&ArtifactSelector::latest_file(RecordId(123), "artifact.tar.gz"))
.await?;
let _ = stream.content_length;
Ok(())
}§Errors
Returns an error if selector resolution fails or if Zenodo returns a non-success response for the resolved download.
Sourcepub async fn download_record_file_by_key_to_path(
&self,
id: RecordId,
key: &str,
path: &Path,
) -> Result<ResolvedDownload, ZenodoError>
pub async fn download_record_file_by_key_to_path( &self, id: RecordId, key: &str, path: &Path, ) -> Result<ResolvedDownload, ZenodoError>
Downloads a named file from a specific record to a local path.
Returns resolution metadata describing the record and file that ultimately produced the bytes.
§Errors
Returns an error if the record lookup fails, if the file is missing, or if writing the destination path fails.
Sourcepub async fn download_record_file_by_key_to_path_with_progress<P>(
&self,
id: RecordId,
key: &str,
path: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
pub async fn download_record_file_by_key_to_path_with_progress<P>(
&self,
id: RecordId,
key: &str,
path: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
Downloads a named file from a specific record to a local path while reporting progress.
Returns resolution metadata describing the record and file that ultimately produced the bytes.
§Errors
Returns an error if the record lookup fails, if the file is missing, or if writing the destination path fails.
Sourcepub async fn download_latest_record_file_by_key_to_path(
&self,
id: RecordId,
key: &str,
path: &Path,
) -> Result<ResolvedDownload, ZenodoError>
pub async fn download_latest_record_file_by_key_to_path( &self, id: RecordId, key: &str, path: &Path, ) -> Result<ResolvedDownload, ZenodoError>
Downloads a named file from the latest record version to a local path.
§Errors
Returns an error if latest-version resolution fails, if the file is missing, or if writing the destination path fails.
Sourcepub async fn download_latest_record_file_by_key_to_path_with_progress<P>(
&self,
id: RecordId,
key: &str,
path: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
pub async fn download_latest_record_file_by_key_to_path_with_progress<P>(
&self,
id: RecordId,
key: &str,
path: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
Downloads a named file from the latest record version to a local path while reporting progress.
§Errors
Returns an error if latest-version resolution fails, if the file is missing, or if writing the destination path fails.
Sourcepub async fn download_record_archive_to_path(
&self,
id: RecordId,
path: &Path,
) -> Result<ResolvedDownload, ZenodoError>
pub async fn download_record_archive_to_path( &self, id: RecordId, path: &Path, ) -> Result<ResolvedDownload, ZenodoError>
Downloads the archive for a specific record to a local path.
Returns resolution metadata describing the record that produced the archive bytes.
§Errors
Returns an error if the record lookup fails, if the archive link is missing, or if writing the destination path fails.
Sourcepub async fn download_record_archive_to_path_with_progress<P>(
&self,
id: RecordId,
path: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
pub async fn download_record_archive_to_path_with_progress<P>(
&self,
id: RecordId,
path: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
Downloads the archive for a specific record to a local path while reporting progress.
Returns resolution metadata describing the record that produced the archive bytes.
§Errors
Returns an error if the record lookup fails, if the archive link is missing, or if writing the destination path fails.
Sourcepub async fn download_file_by_doi_to_path(
&self,
doi: &Doi,
key: &str,
latest: bool,
path: &Path,
) -> Result<ResolvedDownload, ZenodoError>
pub async fn download_file_by_doi_to_path( &self, doi: &Doi, key: &str, latest: bool, path: &Path, ) -> Result<ResolvedDownload, ZenodoError>
Downloads a named file after resolving a DOI to a record.
§Errors
Returns an error if DOI resolution fails, if the file is missing, or if writing the destination path fails.
Sourcepub async fn download_file_by_doi_to_path_with_progress<P>(
&self,
doi: &Doi,
key: &str,
latest: bool,
path: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
pub async fn download_file_by_doi_to_path_with_progress<P>(
&self,
doi: &Doi,
key: &str,
latest: bool,
path: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
Downloads a named file after resolving a DOI to a record while reporting progress.
§Errors
Returns an error if DOI resolution fails, if the file is missing, or if writing the destination path fails.
Sourcepub async fn download_artifact(
&self,
selector: &ArtifactSelector,
destination: &Path,
) -> Result<ResolvedDownload, ZenodoError>
pub async fn download_artifact( &self, selector: &ArtifactSelector, destination: &Path, ) -> Result<ResolvedDownload, ZenodoError>
Downloads an artifact selected by high-level record or DOI selectors.
§Examples
use std::path::Path;
use zenodo_rs::{ArtifactSelector, Auth, ZenodoClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let resolved = client
.download_artifact(
&ArtifactSelector::latest_archive_by_doi("10.5281/zenodo.123")?,
Path::new("record.zip"),
)
.await?;
let _ = resolved.bytes_written;
Ok(())
}§Errors
Returns an error if record resolution fails, if the requested artifact is unavailable, if checksum validation fails, or if writing the destination path fails.
Sourcepub async fn download_artifact_with_progress<P>(
&self,
selector: &ArtifactSelector,
destination: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
pub async fn download_artifact_with_progress<P>(
&self,
selector: &ArtifactSelector,
destination: &Path,
progress: P,
) -> Result<ResolvedDownload, ZenodoError>where
P: TransferProgress,
Downloads an artifact selected by high-level record or DOI selectors while reporting progress.
The supplied progress sink receives the response Content-Length when
Zenodo provides one and one advance event per chunk successfully
written to disk.
§Errors
Returns an error if record resolution fails, if the requested artifact is unavailable, if checksum validation fails, or if writing the destination path fails.
Source§impl ZenodoClient
impl ZenodoClient
Sourcepub async fn search_records(
&self,
query: &RecordQuery,
) -> Result<Page<Record>, ZenodoError>
pub async fn search_records( &self, query: &RecordQuery, ) -> Result<Page<Record>, ZenodoError>
Searches published records using Zenodo’s records API.
§Examples
use zenodo_rs::{Auth, RecordQuery, ZenodoClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let page = client
.search_records(
&RecordQuery::builder()
.query("doi:\"10.5281/zenodo.123\"")
.published()
.most_recent()
.size(10)
.build(),
)
.await?;
let _ = page.hits;
Ok(())
}§Errors
Returns an error if the request fails or Zenodo returns malformed search data.
Sourcepub async fn get_record(&self, id: RecordId) -> Result<Record, ZenodoError>
pub async fn get_record(&self, id: RecordId) -> Result<Record, ZenodoError>
Fetches a published record by record ID.
§Errors
Returns an error if the request fails or Zenodo returns a non-success response.
Sourcepub async fn get_record_by_doi(&self, doi: &Doi) -> Result<Record, ZenodoError>
pub async fn get_record_by_doi(&self, doi: &Doi) -> Result<Record, ZenodoError>
Resolves a DOI to a published record.
§Examples
use zenodo_rs::{Auth, ZenodoClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let record = client
.get_record_by_doi_str("https://doi.org/10.5281/zenodo.123")
.await?;
let _ = record.id;
Ok(())
}§Errors
Returns an error if the search fails or no record matches the DOI.
Sourcepub async fn get_record_by_doi_str(
&self,
doi: impl AsRef<str>,
) -> Result<Record, ZenodoError>
pub async fn get_record_by_doi_str( &self, doi: impl AsRef<str>, ) -> Result<Record, ZenodoError>
Parses a DOI string and resolves it to a published record.
§Errors
Returns an error if the DOI string is invalid, if the search fails, or if no record matches the DOI.
Sourcepub async fn resolve_latest_by_doi(
&self,
doi: &Doi,
) -> Result<Record, ZenodoError>
pub async fn resolve_latest_by_doi( &self, doi: &Doi, ) -> Result<Record, ZenodoError>
Resolves a DOI and then follows the latest-version link when present.
§Errors
Returns an error if DOI resolution fails or the latest record cannot be fetched.
Sourcepub async fn resolve_latest_by_doi_str(
&self,
doi: impl AsRef<str>,
) -> Result<Record, ZenodoError>
pub async fn resolve_latest_by_doi_str( &self, doi: impl AsRef<str>, ) -> Result<Record, ZenodoError>
Parses a DOI string and resolves the latest version in that record family.
§Errors
Returns an error if the DOI string is invalid, if DOI resolution fails, or if the latest record cannot be fetched.
Sourcepub async fn get_latest_record(
&self,
id: RecordId,
) -> Result<Record, ZenodoError>
pub async fn get_latest_record( &self, id: RecordId, ) -> Result<Record, ZenodoError>
Fetches the latest record version for a record family.
§Errors
Returns an error if record lookup fails or the latest record cannot be fetched.
Sourcepub async fn resolve_latest_version(
&self,
id: RecordId,
) -> Result<Record, ZenodoError>
pub async fn resolve_latest_version( &self, id: RecordId, ) -> Result<Record, ZenodoError>
Resolves the latest record version starting from a record ID.
§Errors
Returns an error if record lookup fails or the latest record cannot be fetched.
Sourcepub async fn list_record_versions(
&self,
id: RecordId,
) -> Result<Page<Record>, ZenodoError>
pub async fn list_record_versions( &self, id: RecordId, ) -> Result<Page<Record>, ZenodoError>
Lists the versions associated with a record family.
§Errors
Returns an error if the record lookup fails or the versions query cannot be completed.
Sourcepub async fn list_record_files(
&self,
id: RecordId,
) -> Result<Vec<RecordFile>, ZenodoError>
pub async fn list_record_files( &self, id: RecordId, ) -> Result<Vec<RecordFile>, ZenodoError>
Sourcepub async fn get_artifact_info(
&self,
id: RecordId,
) -> Result<ArtifactInfo, ZenodoError>
pub async fn get_artifact_info( &self, id: RecordId, ) -> Result<ArtifactInfo, ZenodoError>
Returns a record together with its latest version and keyed files map.
§Examples
use zenodo_rs::{Auth, RecordId, ZenodoClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let info = client.get_artifact_info(RecordId(123)).await?;
let _ = info.files_by_key;
Ok(())
}§Errors
Returns an error if record lookup or latest-version resolution fails.
Sourcepub async fn get_artifact_info_by_doi(
&self,
doi: &Doi,
) -> Result<ArtifactInfo, ZenodoError>
pub async fn get_artifact_info_by_doi( &self, doi: &Doi, ) -> Result<ArtifactInfo, ZenodoError>
Resolves artifact information starting from a DOI.
§Errors
Returns an error if DOI resolution fails or latest-version resolution fails.
Source§impl ZenodoClient
impl ZenodoClient
Sourcepub async fn enter_edit_mode(
&self,
id: DepositionId,
) -> Result<Deposition, ZenodoError>
pub async fn enter_edit_mode( &self, id: DepositionId, ) -> Result<Deposition, ZenodoError>
Enters edit mode for the current published version without versioning.
Unpublished depositions are reused directly. Published depositions
trigger edit and then wait until the current deposition becomes
editable again.
§Examples
use zenodo_rs::{Auth, DepositionId, ZenodoClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let draft = client.enter_edit_mode(DepositionId(42)).await?;
let _ = draft.id;
Ok(())
}§Errors
Returns an error if the deposition lookup fails, if Zenodo rejects edit mode, or if the draft never becomes editable.
Sourcepub async fn ensure_editable_draft(
&self,
id: DepositionId,
) -> Result<Deposition, ZenodoError>
pub async fn ensure_editable_draft( &self, id: DepositionId, ) -> Result<Deposition, ZenodoError>
Returns an editable draft for the given deposition ID.
Unpublished depositions are reused directly. Published depositions are
first resolved to the latest published version and then trigger
newversion, after which the helper follows latest_draft.
§Examples
use zenodo_rs::{Auth, DepositionId, ZenodoClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let draft = client.ensure_editable_draft(DepositionId(42)).await?;
let _ = draft.id;
Ok(())
}§Errors
Returns an error if the deposition lookup fails, if Zenodo rejects version creation, or if the resulting draft never becomes available.
Sourcepub async fn replace_all_files<I>(
&self,
draft: &Deposition,
files: I,
) -> Result<Vec<BucketObject>, ZenodoError>where
I: IntoIterator<Item = UploadSpec>,
pub async fn replace_all_files<I>(
&self,
draft: &Deposition,
files: I,
) -> Result<Vec<BucketObject>, ZenodoError>where
I: IntoIterator<Item = UploadSpec>,
Replaces all currently visible draft files with the provided uploads.
§Errors
Returns an error if the draft cannot be refreshed, if the bucket link is missing, if file deletion fails, or if any upload fails.
Sourcepub async fn reconcile_files<I>(
&self,
draft: &Deposition,
policy: FileReplacePolicy,
files: I,
) -> Result<Vec<BucketObject>, ZenodoError>where
I: IntoIterator<Item = UploadSpec>,
pub async fn reconcile_files<I>(
&self,
draft: &Deposition,
policy: FileReplacePolicy,
files: I,
) -> Result<Vec<BucketObject>, ZenodoError>where
I: IntoIterator<Item = UploadSpec>,
Reconciles draft files using the requested replacement policy.
ReplaceAll deletes all currently visible draft files before upload.
UpsertByFilename deletes only draft files whose filename matches one
of the new uploads. KeepExistingAndAdd leaves all existing files in
place and uploads additional files alongside them.
§Examples
use zenodo_rs::{Auth, DepositionId, FileReplacePolicy, UploadSpec, ZenodoClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let draft = client.ensure_editable_draft(DepositionId(42)).await?;
client
.reconcile_files(
&draft,
FileReplacePolicy::UpsertByFilename,
vec![UploadSpec::from_path("artifact.tar.gz")?],
)
.await?;
Ok(())
}§Errors
Returns an error if the draft cannot be refreshed, if the bucket link is missing, if duplicate upload filenames are provided, if a keep-existing upload would overwrite an existing draft filename, if file deletion fails, or if any upload fails.
Sourcepub async fn reconcile_files_with_progress<I, P>(
&self,
draft: &Deposition,
policy: FileReplacePolicy,
files: I,
progress: P,
) -> Result<Vec<BucketObject>, ZenodoError>
pub async fn reconcile_files_with_progress<I, P>( &self, draft: &Deposition, policy: FileReplacePolicy, files: I, progress: P, ) -> Result<Vec<BucketObject>, ZenodoError>
Reconciles a draft’s visible files and reports aggregate upload progress.
The supplied progress sink receives the sum of all upload content
lengths before the first upload starts and one advance event as each
upload streams bytes into the request body.
§Errors
Returns an error if the draft cannot be refreshed, if the bucket link is missing, if duplicate upload filenames are provided, if a keep-existing upload would overwrite an existing draft filename, if reading a source path length fails, if file deletion fails, or if any upload fails.
Sourcepub async fn publish_dataset(
&self,
root: DepositionId,
metadata: &DepositMetadataUpdate,
files: impl IntoIterator<Item = UploadSpec>,
) -> Result<PublishedRecord, ZenodoError>
pub async fn publish_dataset( &self, root: DepositionId, metadata: &DepositMetadataUpdate, files: impl IntoIterator<Item = UploadSpec>, ) -> Result<PublishedRecord, ZenodoError>
Runs the full publish workflow for a deposition.
§Errors
Returns an error if any draft lookup, metadata update, file upload, publish step, or final record lookup fails.
Sourcepub async fn publish_dataset_with_policy(
&self,
root: DepositionId,
metadata: &DepositMetadataUpdate,
policy: FileReplacePolicy,
files: impl IntoIterator<Item = UploadSpec>,
) -> Result<PublishedRecord, ZenodoError>
pub async fn publish_dataset_with_policy( &self, root: DepositionId, metadata: &DepositMetadataUpdate, policy: FileReplacePolicy, files: impl IntoIterator<Item = UploadSpec>, ) -> Result<PublishedRecord, ZenodoError>
Runs the full publish workflow for a deposition using a file policy.
§Examples
use zenodo_rs::{
AccessRight, Auth, Creator, DepositMetadataUpdate, DepositionId, FileReplacePolicy,
UploadSpec, UploadType, ZenodoClient,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let metadata = DepositMetadataUpdate::builder()
.title("Example dataset")
.upload_type(UploadType::Dataset)
.description_html("<p>Example upload</p>")
.creator(Creator::builder().name("Doe, Jane").build()?)
.access_right(AccessRight::Open)
.build()?;
let published = client
.publish_dataset_with_policy(
DepositionId(42),
&metadata,
FileReplacePolicy::KeepExistingAndAdd,
vec![UploadSpec::from_path("artifact.tar.gz")?],
)
.await?;
let _ = published.record.id;
Ok(())
}§Errors
Returns an error if any draft lookup, metadata update, file upload, publish step, duplicate/conflicting filename validation, or final record lookup fails.
Sourcepub async fn create_and_publish_dataset(
&self,
metadata: &DepositMetadataUpdate,
files: impl IntoIterator<Item = UploadSpec>,
) -> Result<PublishedRecord, ZenodoError>
pub async fn create_and_publish_dataset( &self, metadata: &DepositMetadataUpdate, files: impl IntoIterator<Item = UploadSpec>, ) -> Result<PublishedRecord, ZenodoError>
Creates a fresh deposition and runs the full publish workflow.
This is the ergonomic entrypoint for “publish a new dataset now” automation that does not already have a deposition ID.
§Examples
use zenodo_rs::{
AccessRight, Auth, DepositMetadataUpdate, UploadSpec, UploadType, ZenodoClient,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZenodoClient::new(Auth::new("token"))?;
let metadata = DepositMetadataUpdate::builder()
.title("Example dataset")
.upload_type(UploadType::Dataset)
.description_html("<p>Example upload</p>")
.creator_named("Doe, Jane")
.access_right(AccessRight::Open)
.build()?;
let published = client
.create_and_publish_dataset(
&metadata,
vec![UploadSpec::from_path_as(
"target/release.tar.gz",
"archive.tar.gz",
)?],
)
.await?;
let _ = published.record.id;
Ok(())
}§Errors
Returns an error if deposition creation fails or if any later metadata update, file upload, publish step, or final record lookup fails.
Sourcepub async fn create_and_publish_dataset_with_policy(
&self,
metadata: &DepositMetadataUpdate,
policy: FileReplacePolicy,
files: impl IntoIterator<Item = UploadSpec>,
) -> Result<PublishedRecord, ZenodoError>
pub async fn create_and_publish_dataset_with_policy( &self, metadata: &DepositMetadataUpdate, policy: FileReplacePolicy, files: impl IntoIterator<Item = UploadSpec>, ) -> Result<PublishedRecord, ZenodoError>
Creates a fresh deposition and runs the full publish workflow with a file policy.
§Errors
Returns an error if deposition creation fails or if any later metadata update, file upload, publish step, duplicate/conflicting filename validation, or final record lookup fails.
Trait Implementations§
Source§impl ClientContext for ZenodoClient
impl ClientContext for ZenodoClient
Source§type PollOptions = PollOptions
type PollOptions = PollOptions
Source§type Error = ZenodoError
type Error = ZenodoError
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§impl Clone for ZenodoClient
impl Clone for ZenodoClient
Source§fn clone(&self) -> ZenodoClient
fn clone(&self) -> ZenodoClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more