oai-pmh

Crates.iooai-pmh
lib.rsoai-pmh
version0.3.0
created_at2025-12-15 18:35:00.022851+00
updated_at2025-12-22 03:16:43.835719+00
descriptionRust library for the Open Archives Initiative Protocol for Metadata Harvesting
homepage
repository
max_upload_size
id1986516
size275,132
Mark Cooper (mark-cooper)

documentation

README

oai-pmh

Rust library for the Open Archives Initiative Protocol for Metadata Harvesting.

The immediate need and focus is for a client only. A repository may come later.

Usage

The standard practice will be to:

  • Create a client passing in the OAI endpoint
  • Create query args as necessary
  • Run the query
use oai_pmh::{Client, ListRecordsArgs, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let client = Client::new("https://demo.archivesspace.org/oai")?;

    let response = client.identify().await?;
    println!("{:?}", response.payload);

    let args = ListRecordsArgs::new("oai_dc");
    let mut stream = client.list_records(args).await?;
    while let Some(response) = stream.next().await {
        println!("{:?}", response);
        break;
    }

    Ok(())
}

Queries that support resumption tokens return an async stream, as in client.list_records in the example.

Metadata

To provide flexibilty metadata is not parsed by this library. The OAI response metadata element/s are captured as strings. The expectation is you "bring your own parser" to handle whatever metadata format is supported by the server and requested via the client.

Runnable Examples

List identifiers:

# Use defaults (test.archivesspace.org, oai_ead, 5 responses/pages)
cargo run --example list_identifiers

# Specify endpoint and metadata prefix
cargo run --example list_identifiers https://test.archivesspace.org oai_ead

# Specify number of respones/pages to fetch
cargo run --example list_identifiers https://test.archivesspace.org oai_ead 100

# Specify a different endpoint and metadata format
cargo run --example list_identifiers https://demo.archivesspace.org/oai oai_dc 5

# Basic profiling
cargo build --release --example list_identifiers
/usr/bin/time -v cargo run --example list_identifiers -- https://test.archivesspace.org/oai oai_ead 200

Other examples include:

  • List formats and sets
  • List records
Commit count: 0

cargo fmt