Skip to content

Commit 0070ab2

Browse files
committed
Rename generic
1 parent c2bb563 commit 0070ab2

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

typesense/src/client/collection/document.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ use typesense_codegen::apis::documents_api;
1313
/// This struct is created by calling a method like `client.collection("collection_name").document("document_id")` or `client.collection_of::<MyType>("collection_name").document("document_id")`.
1414
/// The generic `T` represents the shape of the document and must implement `Serialize` and `DeserializeOwned`.
1515
/// If `T` is not specified, it defaults to `serde_json::Value` for schemaless interactions.
16-
pub struct Document<'c, 'n, T = serde_json::Value>
16+
pub struct Document<'c, 'n, D = serde_json::Value>
1717
where
18-
T: DeserializeOwned + Serialize + Send + Sync,
18+
D: DeserializeOwned + Serialize + Send + Sync,
1919
{
2020
pub(super) client: &'c Client,
2121
pub(super) collection_name: &'n str,
2222
pub(super) document_id: String,
23-
pub(super) _phantom: std::marker::PhantomData<T>,
23+
pub(super) _phantom: std::marker::PhantomData<D>,
2424
}
2525

26-
impl<'c, 'n, T> Document<'c, 'n, T>
26+
impl<'c, 'n, D> Document<'c, 'n, D>
2727
where
28-
T: DeserializeOwned + Serialize + Send + Sync,
28+
D: DeserializeOwned + Serialize + Send + Sync,
2929
{
3030
/// Creates a new `Document` instance for a specific document ID.
3131
#[inline]
@@ -42,7 +42,7 @@ where
4242
///
4343
/// # Returns
4444
/// A `Result` containing the strongly-typed document `T` if successful.
45-
pub async fn retrieve(&self) -> Result<T, Error<documents_api::GetDocumentError>> {
45+
pub async fn retrieve(&self) -> Result<D, Error<documents_api::GetDocumentError>> {
4646
let params = documents_api::GetDocumentParams {
4747
collection_name: self.collection_name.to_owned(),
4848
document_id: self.document_id.to_owned(),
@@ -100,7 +100,7 @@ where
100100
&self,
101101
partial_document: U,
102102
params: Option<crate::models::DocumentIndexParameters>,
103-
) -> Result<T, Error<documents_api::UpdateDocumentError>> {
103+
) -> Result<D, Error<documents_api::UpdateDocumentError>> {
104104
let params = documents_api::UpdateDocumentParams {
105105
collection_name: self.collection_name.to_owned(),
106106
document_id: self.document_id.to_owned(),
@@ -119,7 +119,7 @@ where
119119
///
120120
/// # Returns
121121
/// A `Result` containing the deleted document deserialized into `T`.
122-
pub async fn delete(&self) -> Result<T, Error<documents_api::DeleteDocumentError>> {
122+
pub async fn delete(&self) -> Result<D, Error<documents_api::DeleteDocumentError>> {
123123
let params = documents_api::DeleteDocumentParams {
124124
collection_name: self.collection_name.to_owned(),
125125
document_id: self.document_id.to_owned(),

typesense/src/client/collection/documents.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ use typesense_codegen::{
2121
/// This struct is generic over the document type `T`. If created via `client.collection(...)`,
2222
/// `T` defaults to `serde_json::Value`. If created via `client.collection_of::<MyType>(...)`,
2323
/// `T` will be `MyType`.
24-
pub struct Documents<'c, 'n, T = serde_json::Value>
24+
pub struct Documents<'c, 'n, D = serde_json::Value>
2525
where
26-
T: DeserializeOwned + Serialize + Send + Sync,
26+
D: DeserializeOwned + Serialize + Send + Sync,
2727
{
2828
pub(super) client: &'c Client,
2929
pub(super) collection_name: &'n str,
30-
pub(super) _phantom: std::marker::PhantomData<T>,
30+
pub(super) _phantom: std::marker::PhantomData<D>,
3131
}
3232

33-
impl<'c, 'n, T> Documents<'c, 'n, T>
33+
impl<'c, 'n, D> Documents<'c, 'n, D>
3434
where
35-
T: DeserializeOwned + Serialize + Send + Sync,
35+
D: DeserializeOwned + Serialize + Send + Sync,
3636
{
3737
/// Creates a new `Documents` instance.
3838
#[inline]
@@ -76,7 +76,7 @@ where
7676
&self,
7777
document: U,
7878
params: Option<DocumentIndexParameters>,
79-
) -> Result<T, Error<documents_api::IndexDocumentError>> {
79+
) -> Result<D, Error<documents_api::IndexDocumentError>> {
8080
let doc_value = serde_json::to_value(document)?;
8181
let result_value = self.index(doc_value, "create", params).await?;
8282
serde_json::from_value(result_value).map_err(Error::from)
@@ -94,7 +94,7 @@ where
9494
&self,
9595
document: U,
9696
params: Option<DocumentIndexParameters>,
97-
) -> Result<T, Error<documents_api::IndexDocumentError>> {
97+
) -> Result<D, Error<documents_api::IndexDocumentError>> {
9898
let doc_value = serde_json::to_value(document)?;
9999
let result_value = self.index(doc_value, "upsert", params).await?;
100100
serde_json::from_value(result_value).map_err(Error::from)
@@ -191,7 +191,7 @@ where
191191
pub async fn search(
192192
&self,
193193
params: raw_models::SearchParameters,
194-
) -> Result<SearchResult<T>, Error<documents_api::SearchCollectionError>> {
194+
) -> Result<SearchResult<D>, Error<documents_api::SearchCollectionError>> {
195195
let search_params = documents_api::SearchCollectionParams {
196196
collection_name: self.collection_name.to_owned(),
197197

typesense/src/client/collection/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ use typesense_codegen::{apis::collections_api, models};
1212
/// Provides methods for interacting with a Typesense collection.
1313
///
1414
/// This struct is created by calling `client.collection("collection_name")`.
15-
pub struct Collection<'c, 'n, T = serde_json::Value>
15+
pub struct Collection<'c, 'n, D = serde_json::Value>
1616
where
17-
T: DeserializeOwned + Serialize + Send + Sync,
17+
D: DeserializeOwned + Serialize + Send + Sync,
1818
{
1919
pub(super) client: &'c Client,
2020
pub(super) collection_name: &'n str,
21-
pub(super) _phantom: std::marker::PhantomData<T>,
21+
pub(super) _phantom: std::marker::PhantomData<D>,
2222
}
2323

24-
impl<'c, 'n, T> Collection<'c, 'n, T>
24+
impl<'c, 'n, D> Collection<'c, 'n, D>
2525
where
26-
T: DeserializeOwned + Serialize + Send + Sync,
26+
D: DeserializeOwned + Serialize + Send + Sync,
2727
{
2828
/// Creates a new `Collection` instance.
2929
#[inline]
@@ -37,13 +37,13 @@ where
3737

3838
/// Provides access to the document-related API endpoints for a specific collection.
3939
#[inline]
40-
pub fn documents(&self) -> documents::Documents<'c, 'n, T> {
40+
pub fn documents(&self) -> documents::Documents<'c, 'n, D> {
4141
documents::Documents::new(self.client, self.collection_name)
4242
}
4343

4444
/// Provides access to the API endpoints for a single document within a Typesense collection.
4545
#[inline]
46-
pub fn document(&self, document_id: impl Into<String>) -> document::Document<'c, 'n, T> {
46+
pub fn document(&self, document_id: impl Into<String>) -> document::Document<'c, 'n, D> {
4747
document::Document::new(self.client, self.collection_name, document_id.into())
4848
}
4949

0 commit comments

Comments
 (0)