Skip to main content

exa_async/resources/
find_similar.rs

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