1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Provides access to the API endpoints for managing stopwords sets.
//!
//! A `Stopwords` instance is created via the main `client.stopwords()` method.
use crate::{Client, Error, execute_wrapper};
use ::std::borrow::Cow;
use typesense_codegen::{apis::stopwords_api, models};
/// Provides methods for managing Typesense stopwords sets.
///
/// This struct is created by calling `client.stopwords()`.
pub struct Stopwords<'a> {
pub(super) client: &'a Client,
}
impl<'a> Stopwords<'a> {
/// Creates a new `Stopwords` instance.
#[inline]
pub(super) fn new(client: &'a Client) -> Self {
Self { client }
}
/// Creates or updates an existing stopwords set.
///
/// # Arguments
/// * `set_id` - The ID of the stopwords set to create or update.
/// * `schema` - A `StopwordsSetUpsertSchema` object with the stopwords to upsert.
pub async fn upsert(
&self,
set_id: impl Into<Cow<'_, str>>,
schema: models::StopwordsSetUpsertSchema<'_>,
) -> Result<models::StopwordsSetSchema, Error<stopwords_api::UpsertStopwordsSetError>> {
let params = stopwords_api::UpsertStopwordsSetParams {
set_id: set_id.into(),
stopwords_set_upsert_schema: schema,
};
execute_wrapper!(self, stopwords_api::upsert_stopwords_set, params)
}
/// Retrieves the details of all stopwords sets.
pub async fn retrieve(
&self,
) -> Result<
models::StopwordsSetsRetrieveAllSchema,
Error<stopwords_api::RetrieveStopwordsSetsError>,
> {
execute_wrapper!(self, stopwords_api::retrieve_stopwords_sets)
}
}