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.
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?;
if let Some(response) = stream.try_next().await? {
println!("{:?}", response);
}
Ok(())
}Queries that support resumption tokens return an async stream, as in client.list_records in the example.
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.
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 200Other examples include:
- List formats and sets
- List records