Skip to main content

exa_async/resources/
contents.rs

1use crate::client::Client;
2use crate::config::Config;
3use crate::error::ExaError;
4use crate::types::contents::ContentsRequest;
5use crate::types::contents::ContentsResponse;
6
7/// API resource for the `/contents` endpoint
8pub struct Contents<'c, C: Config> {
9    client: &'c Client<C>,
10}
11
12impl<'c, C: Config> Contents<'c, C> {
13    /// Creates a new Contents resource
14    #[must_use]
15    pub const fn new(client: &'c Client<C>) -> Self {
16        Self { client }
17    }
18
19    /// Retrieve content for a list of URLs
20    ///
21    /// # Errors
22    ///
23    /// Returns an error if the request fails or the API returns an error.
24    pub async fn create(&self, req: ContentsRequest) -> Result<ContentsResponse, ExaError> {
25        self.client.post("/contents", req).await
26    }
27}
28
29impl<C: Config> crate::Client<C> {
30    /// Returns the Contents API resource
31    #[must_use]
32    pub const fn contents(&self) -> Contents<'_, C> {
33        Contents::new(self)
34    }
35}