Skip to main content

InternetArchiveClient

Struct InternetArchiveClient 

Source
pub struct InternetArchiveClient { /* private fields */ }
Expand description

Typed async client for Internet Archive metadata, search, uploads, and downloads.

Implementations§

Source§

impl InternetArchiveClient

Source

pub fn builder() -> InternetArchiveClientBuilder

Starts building a client.

Source

pub fn new() -> Result<Self, InternetArchiveError>

Builds an unauthenticated client.

§Errors

Returns an error if the underlying HTTP clients cannot be built.

Source

pub fn with_auth(auth: Auth) -> Result<Self, InternetArchiveError>

Builds a client with explicit credentials.

§Errors

Returns an error if the underlying HTTP clients cannot be built.

Source

pub fn from_env() -> Result<Self, InternetArchiveError>

Builds a client from the standard Internet Archive environment variables.

§Errors

Returns an error if the environment variables are missing or if the underlying HTTP clients cannot be built.

Source

pub fn endpoint(&self) -> &Endpoint

Returns the configured endpoint roots.

Source

pub fn poll_options(&self) -> &PollOptions

Returns the configured workflow polling options.

Source

pub fn request_timeout(&self) -> Option<Duration>

Returns the request timeout.

Source

pub fn connect_timeout(&self) -> Option<Duration>

Returns the connect timeout.

Source

pub fn has_auth(&self) -> bool

Returns whether the client currently has credentials configured.

Source

pub async fn get_item( &self, identifier: &ItemIdentifier, ) -> Result<Item, InternetArchiveError>

Fetches a full item metadata record by identifier.

§Errors

Returns an error if the request fails or the item does not exist.

Source

pub async fn get_item_by_str( &self, identifier: impl AsRef<str>, ) -> Result<Item, InternetArchiveError>

Fetches a full item metadata record from a string identifier.

§Errors

Returns an error if the identifier is invalid, the request fails, or the item does not exist.

Source

pub async fn search( &self, query: &SearchQuery, ) -> Result<SearchResponse, InternetArchiveError>

Runs an advanced search query.

§Errors

Returns an error if the request fails or the response is invalid.

Source

pub async fn check_upload_limit( &self, identifier: &ItemIdentifier, ) -> Result<S3LimitCheck, InternetArchiveError>

Checks whether the S3 queue is currently over its documented upload limit.

§Errors

Returns an error if the client has no credentials or if the request fails.

Source

pub async fn apply_metadata_patch( &self, identifier: &ItemIdentifier, target: MetadataTarget, patch: &[PatchOperation], ) -> Result<MetadataWriteResponse, InternetArchiveError>

Applies a single-target metadata patch document.

§Errors

Returns an error if the client has no credentials, the request fails, or MDAPI rejects the patch.

Source

pub async fn apply_metadata_changes( &self, identifier: &ItemIdentifier, changes: &[MetadataChange], ) -> Result<MetadataWriteResponse, InternetArchiveError>

Applies an atomic multi-target metadata write.

§Errors

Returns an error if the client has no credentials, the request fails, or MDAPI rejects the patch document.

Source

pub async fn update_item_metadata( &self, identifier: &ItemIdentifier, metadata: &ItemMetadata, ) -> Result<MetadataWriteResponse, InternetArchiveError>

Updates the item-level metadata document by overlaying the provided keys onto the current metadata and diffing the result.

Missing keys in metadata are left untouched. Existing entries within list-valued fields (for example collection, subject, language) are also preserved; the update set is unioned into them. Use Self::apply_metadata_patch when you want exact JSON Patch behavior, including removing individual list entries or whole keys.

If there are no effective changes, the method returns a synthetic successful response with no task id and does not require authentication.

§Errors

Returns an error if the client has no credentials, the item cannot be fetched, or the patch cannot be applied.

Source

pub async fn upload_file( &self, identifier: &ItemIdentifier, spec: &UploadSpec, options: &UploadOptions, ) -> Result<(), InternetArchiveError>

Uploads a file to an existing item.

§Errors

Returns an error if the client has no credentials, the request fails, or IA rejects the upload.

Source

pub async fn upload_file_with_progress( &self, identifier: &ItemIdentifier, spec: &UploadSpec, options: &UploadOptions, progress: &ProgressBar, ) -> Result<(), InternetArchiveError>

Uploads a file to an existing item while updating an indicatif progress bar.

Available when the indicatif feature is enabled.

§Errors

Returns an error if the client has no credentials, the request fails, or IA rejects the upload.

Source

pub async fn create_item( &self, identifier: &ItemIdentifier, metadata: &ItemMetadata, spec: &UploadSpec, options: &UploadOptions, ) -> Result<(), InternetArchiveError>

Creates a new item by uploading the first file with automatic bucket creation headers and initial metadata.

§Errors

Returns an error if the identifier is not valid for IA-S3 bucket creation, the client has no credentials, the request fails, or IA rejects the upload.

Source

pub async fn create_item_with_progress( &self, identifier: &ItemIdentifier, metadata: &ItemMetadata, spec: &UploadSpec, options: &UploadOptions, progress: &ProgressBar, ) -> Result<(), InternetArchiveError>

Creates a new item while updating an indicatif progress bar for the initial upload step.

Available when the indicatif feature is enabled.

§Errors

Returns an error if the identifier is not valid for IA-S3 bucket creation, the client has no credentials, the request fails, or IA rejects the upload.

Source

pub async fn delete_file( &self, identifier: &ItemIdentifier, filename: &str, options: &DeleteOptions, ) -> Result<(), InternetArchiveError>

Deletes a file from an item through the S3-like API.

§Errors

Returns an error if the client has no credentials, the request fails, or IA rejects the delete.

Source

pub async fn make_dark( &self, identifier: &ItemIdentifier, comment: &str, ) -> Result<TaskSubmission, InternetArchiveError>

Submits a make_dark.php task to the Internet Archive catalog tasks API, hiding the item from public view.

Darkening makes the item unavailable to all users, including the uploader and IA’s metadata and search subsystems; the item’s metadata stub remains with is_dark: true, but /details/{id} returns 404 and search no longer indexes it. The caller must have uploaded the item or otherwise have edit permission. The comment argument is recorded in the task log; supply a short rationale (for example "live test cleanup").

§Errors

Returns an error if the client has no credentials, the request fails, or IA rejects the task submission (for example with 401 when the caller does not own the item).

Source

pub fn resolve_download( &self, identifier: &ItemIdentifier, filename: &str, ) -> Result<ResolvedDownload, InternetArchiveError>

Resolves the public download URL for a file.

§Errors

Returns an error if URL construction fails.

Source

pub async fn download_bytes( &self, identifier: &ItemIdentifier, filename: &str, ) -> Result<Bytes, InternetArchiveError>

Downloads a file into memory.

§Errors

Returns an error if the request fails.

Source

pub async fn download_bytes_with_progress( &self, identifier: &ItemIdentifier, filename: &str, progress: &ProgressBar, ) -> Result<Bytes, InternetArchiveError>

Downloads a file into memory while updating an indicatif progress bar.

Available when the indicatif feature is enabled.

§Errors

Returns an error if the request fails.

Source

pub async fn download_to_path( &self, identifier: &ItemIdentifier, filename: &str, path: impl AsRef<Path>, ) -> Result<(), InternetArchiveError>

Downloads a file to a local path.

§Errors

Returns an error if the request or local file write fails.

Source

pub async fn download_to_path_with_progress( &self, identifier: &ItemIdentifier, filename: &str, path: impl AsRef<Path>, progress: &ProgressBar, ) -> Result<(), InternetArchiveError>

Downloads a file to a local path while updating an indicatif progress bar.

Available when the indicatif feature is enabled.

§Errors

Returns an error if the request or local file write fails.

Source§

impl InternetArchiveClient

Source

pub async fn publish_item( &self, request: PublishRequest, ) -> Result<PublishOutcome, InternetArchiveError>

Creates a brand-new item and uploads all requested files.

§Errors

Returns an error if the identifier is not valid for IA-S3 bucket creation, the item already exists, the request has no files, or any network step fails.

Source

pub async fn upsert_item( &self, request: PublishRequest, ) -> Result<PublishOutcome, InternetArchiveError>

Creates or updates an item using the provided upload conflict policy.

§Errors

Returns an error if the identifier is not valid for IA-S3 bucket creation when a new item must be created, or if any required network step fails.

Trait Implementations§

Source§

impl ClientContext for InternetArchiveClient

Source§

type Endpoint = Endpoint

Service-specific endpoint configuration type.
Source§

type PollOptions = PollOptions

Service-specific polling configuration type.
Source§

type Error = InternetArchiveError

Service-specific error type.
Source§

fn endpoint(&self) -> &Self::Endpoint

Returns the configured endpoint roots.
Source§

fn poll_options(&self) -> &Self::PollOptions

Returns the configured polling behavior.
Source§

fn request_timeout(&self) -> Option<Duration>

Returns the overall request timeout, when configured.
Source§

fn connect_timeout(&self) -> Option<Duration>

Returns the TCP connect timeout, when configured.
Source§

impl Clone for InternetArchiveClient

Source§

fn clone(&self) -> InternetArchiveClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CreatePublication for InternetArchiveClient

Source§

type CreateTarget = ItemIdentifier

Caller-supplied creation target type.
Source§

type Metadata = ItemMetadata

Service-specific metadata type.
Source§

type Upload = UploadSpec

Service-specific upload specification type.
Source§

type Output = PublishOutcome

Service-specific workflow result type.
Source§

fn create_publication( &self, request: CreatePublicationRequest<Self::CreateTarget, Self::Metadata, Self::Upload>, ) -> impl Future<Output = Result<Self::Output, Self::Error>>

Runs the service’s “create a new published resource” workflow.
Source§

impl Debug for InternetArchiveClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DownloadNamedPublicFile for InternetArchiveClient

Source§

type ResourceId = ItemIdentifier

Service-specific resource identifier type.
Source§

type Download = ResolvedDownload

Service-specific download result metadata.
Source§

async fn download_named_public_file_to_path( &self, id: &Self::ResourceId, name: &str, path: &Path, ) -> Result<Self::Download, Self::Error>

Downloads one named file from a public resource.
Source§

impl ListResourceFiles for InternetArchiveClient

Source§

type ResourceId = ItemIdentifier

Service-specific resource identifier type.
Source§

type File = ItemFile

Service-specific file entry type.
Source§

async fn list_resource_files( &self, id: &Self::ResourceId, ) -> Result<Vec<Self::File>, Self::Error>

Returns the complete visible file list for the resource.
Source§

impl MaybeAuthenticatedClient for InternetArchiveClient

Source§

fn has_auth(&self) -> bool

Returns whether the client currently has credentials available for authenticated calls.
Source§

impl ReadPublicResource for InternetArchiveClient

Source§

type ResourceId = ItemIdentifier

Service-specific resource identifier type.
Source§

type Resource = Item

Returned public resource payload.
Source§

fn get_public_resource( &self, id: &Self::ResourceId, ) -> impl Future<Output = Result<Self::Resource, Self::Error>>

Fetches one public resource.
Source§

impl SearchPublicResources for InternetArchiveClient

Source§

type Query = SearchQuery

Service-specific query type.
Source§

type SearchResults = SearchResponse

Service-specific search result shape.
Source§

fn search_public_resources( &self, query: &Self::Query, ) -> impl Future<Output = Result<Self::SearchResults, Self::Error>>

Executes a public search request.
Source§

impl UpdatePublication for InternetArchiveClient

Source§

type ResourceId = ItemIdentifier

Service-specific resource identifier type.
Source§

type Metadata = ItemMetadata

Service-specific metadata type.
Source§

type FilePolicy = FileConflictPolicy

Service-specific upload-policy type.
Source§

type Upload = UploadSpec

Service-specific upload specification type.
Source§

type Output = PublishOutcome

Service-specific workflow result type.
Source§

fn update_publication( &self, request: UpdatePublicationRequest<Self::ResourceId, Self::Metadata, Self::FilePolicy, Self::Upload>, ) -> impl Future<Output = Result<Self::Output, Self::Error>>

Runs the service’s “update or upsert an existing resource” workflow.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> CoreRepositoryClient for T