Expand description
§hal-sdk
An asynchronous Rust SDK for the HAL open-archive search API.
§What is HAL?
HAL (Hyper Articles en Ligne) is a French open-access repository operated by the CCSD. Researchers deposit scholarly documents there — articles, preprints, theses, conference papers, reports — so that they remain freely available to everyone. It hosts millions of records, many of them in French, though the archive is multilingual and international.
HAL exposes a public HTTP search API (backed by Apache Solr) documented at https://api.archives-ouvertes.fr/docs/search. This crate wraps that API in idiomatic, strongly typed Rust.
§Design
The client is async and works on both native targets and wasm32
(in the browser it uses the fetch API through reqwest). The HAL API sends
Access-Control-Allow-Origin: *, so it can be queried directly from a web page.
§Quick start
use hal_sdk::HalClient;
let client = HalClient::new();
let results = client.basic_search("programmation").await?;
println!("{} documents found", results.num_found());
for doc in results.docs() {
println!("{} — {:?}", doc.docid, doc.label_s);
}§Building richer queries
SearchQuery is a builder covering every search mode described in the HAL
documentation: search within a field, several terms in a field, proximity
search, field selection (fl), pagination and facets.
use hal_sdk::{HalClient, SearchQuery};
let client = HalClient::new();
let query = SearchQuery::field("title_t", "europe")
.fields(["docid", "label_s", "title_s", "authFullName_s", "producedDate_s"])
.facet("docType_s")
.page(0, 20);
let results = client.search(&query).await?;§History
This crate is the companion project of chapter 16 (“Projet final : coder et
publier une caisse”) of the book Rust by Benoît Prieur, brought up to date:
the original chapter shipped a minimal, blocking, basic-search-only library
(apiarchivesouvertesrust 0.1). This version modernises it into a complete,
asynchronous, WebAssembly-capable SDK.
Structs§
- Facet
Counts - Solr-style facet counts.
- HalClient
- An asynchronous client for the HAL search API.
- HalDoc
- A single document returned by a HAL search.
- Response
Body - The
responseobject of a HAL search payload. - Search
Query - A builder for HAL search queries.
- Search
Response - The top-level payload returned by the HAL search endpoint.
Enums§
- Field
- A HAL search field usable for fine-grained (field-scoped) searches.
- HalError
- Errors that can occur while talking to the HAL API.
Constants§
- VERSION
- The crate version, as published on crates.io.