Skip to main content

CatalogClient

Struct CatalogClient 

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

Async client for the Catalog API.

Holds an Arc<Configuration> so it’s cheap to clone and share across tasks. Every method is async and returns Result<_, CatalogError>.

Implementations§

Source§

impl CatalogClient

Source

pub fn new(configuration: Arc<Configuration>) -> Self

Construct a new client from a shared Configuration.

Source

pub async fn search( &self, params: SearchParams, ) -> Result<SearchResponse, CatalogError>

Search datasets. See the module docs for parameters.

§Errors

Returns CatalogError::ApiError if the server returns non-2xx, CatalogError::RequestError for network/TLS failure, and CatalogError::ParseError if the response isn’t a valid SearchResponse.

Source

pub async fn dataset_by_slug( &self, slug: &str, ) -> Result<Option<SearchHit>, CatalogError>

Fetch a single dataset by its data.gov slug.

Returns Ok(None) if no dataset with that slug exists. The returned SearchHit carries the denormalized fields and a nested dcat record with the full DCAT-US 3 metadata.

§Notes

The Catalog API does not actually honor a slug= query parameter today — it returns the top relevance hit regardless of the value. We work around this by using a full-text query (q=<slug>) and then scanning the first page for a hit whose slug exactly matches. Slug-shaped queries reliably rank the exact match first when it exists; we look at the top 20 results to leave headroom for ties.

Source

pub async fn organizations(&self) -> Result<OrganizationsResponse, CatalogError>

List all organizations known to the catalog.

The endpoint returns the full list in one response; there is no pagination today.

Source

pub async fn keywords( &self, size: Option<i32>, min_count: Option<i32>, ) -> Result<KeywordsResponse, CatalogError>

Return the top keywords ranked by document frequency.

size caps the number of rows (server default 100, max 1000). min_count drops keywords with fewer than that many datasets.

Autocomplete against known locations.

Source

pub async fn location_geometry(&self, id: &str) -> Result<Value, CatalogError>

Fetch the GeoJSON geometry for a given location id.

The response is returned as a raw serde_json::Value because the shape is unconstrained GeoJSON and callers typically hand it straight to a mapping library.

Source

pub async fn harvest_record( &self, id: &str, ) -> Result<HarvestRecord, CatalogError>

Retrieve a harvest record’s metadata envelope.

Source

pub async fn harvest_record_raw(&self, id: &str) -> Result<Value, CatalogError>

Retrieve the raw (pre-transform) payload a harvester ingested.

The payload is not constrained to a single shape — agencies post JSON, XML fragments, and DCAT records through the same surface — so the result is returned as serde_json::Value.

Source

pub async fn harvest_record_transformed( &self, id: &str, ) -> Result<Dataset, CatalogError>

Retrieve the DCAT-US 3 transform of a harvest record.

Trait Implementations§

Source§

impl Debug for CatalogClient

Source§

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

Formats the value using the given formatter. Read more

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> 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: Sized + 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: Sized + 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, 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