File tree 8 files changed +17
-13
lines changed
types_derive_internals/src/elastic_type
8 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ use types::document::{
34
34
StaticIndex ,
35
35
StaticType ,
36
36
} ;
37
- use types:: DEFAULT_TYPE ;
37
+ use types:: document :: DEFAULT_DOC_TYPE ;
38
38
39
39
/**
40
40
A [delete document request][docs-delete] builder that can be configured before sending.
@@ -181,7 +181,7 @@ where
181
181
self . inner ,
182
182
DeleteRequestInner {
183
183
index : index. into ( ) ,
184
- ty : DEFAULT_TYPE . into ( ) ,
184
+ ty : DEFAULT_DOC_TYPE . into ( ) ,
185
185
id : id. into ( ) ,
186
186
_marker : PhantomData ,
187
187
} ,
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ use types::document::{
35
35
StaticIndex ,
36
36
StaticType ,
37
37
} ;
38
- use types:: DEFAULT_TYPE ;
38
+ use types:: document :: DEFAULT_DOC_TYPE ;
39
39
40
40
/**
41
41
A [get document request][docs-get] builder that can be configured before sending.
@@ -176,7 +176,7 @@ where
176
176
self . inner ,
177
177
GetRequestInner {
178
178
index : index. into ( ) ,
179
- ty : DEFAULT_TYPE . into ( ) ,
179
+ ty : DEFAULT_DOC_TYPE . into ( ) ,
180
180
id : id. into ( ) ,
181
181
_marker : PhantomData ,
182
182
} ,
Original file line number Diff line number Diff line change @@ -33,8 +33,7 @@ use error::{
33
33
Error ,
34
34
Result ,
35
35
} ;
36
- use types:: document:: DocumentType ;
37
- use types:: DEFAULT_TYPE ;
36
+ use types:: document:: { DocumentType , DEFAULT_DOC_TYPE } ;
38
37
39
38
/**
40
39
An [index request][docs-index] builder that can be configured before sending.
@@ -198,7 +197,7 @@ where
198
197
self . inner ,
199
198
IndexRequestInner {
200
199
index : index. into ( ) ,
201
- ty : DEFAULT_TYPE . into ( ) ,
200
+ ty : DEFAULT_DOC_TYPE . into ( ) ,
202
201
id : None ,
203
202
doc : doc,
204
203
} ,
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ use types::document::{
35
35
DocumentType ,
36
36
StaticIndex ,
37
37
StaticType ,
38
+ DEFAULT_DOC_TYPE ,
38
39
} ;
39
- use types:: DEFAULT_TYPE ;
40
40
41
41
pub use client:: requests:: common:: {
42
42
DefaultParams ,
@@ -287,7 +287,7 @@ where
287
287
self . inner ,
288
288
UpdateRequestInner {
289
289
index : index. into ( ) ,
290
- ty : DEFAULT_TYPE . into ( ) ,
290
+ ty : DEFAULT_DOC_TYPE . into ( ) ,
291
291
id : id. into ( ) ,
292
292
body : Doc :: empty ( ) ,
293
293
_marker : PhantomData ,
Original file line number Diff line number Diff line change @@ -275,7 +275,5 @@ pub use elastic_types::{
275
275
string,
276
276
} ;
277
277
278
- pub ( crate ) const DEFAULT_TYPE : & ' static str = "doc" ;
279
-
280
278
#[ doc( hidden) ]
281
279
pub use elastic_types:: derive;
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ pub use document::mapping::{
34
34
PropertiesMapping ,
35
35
} ;
36
36
pub use document:: {
37
+ DEFAULT_DOC_TYPE ,
37
38
DocumentType ,
38
39
StaticIndex ,
39
40
StaticType ,
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ use serde_json::Value;
8
8
use std:: borrow:: Cow ;
9
9
use std:: marker:: PhantomData ;
10
10
11
+ /**
12
+ The default name for document types in a single document index.
13
+ */
14
+ pub const DEFAULT_DOC_TYPE : & ' static str = "doc" ;
15
+
11
16
/**
12
17
An indexable Elasticsearch type.
13
18
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ fn get_doc_ty_impl_block(
164
164
165
165
// Get the default method blocks for `DocumentType`
166
166
fn get_doc_type_methods (
167
+ crate_root : & Tokens ,
167
168
item : & syn:: MacroInput ,
168
169
fields : & [ ( syn:: Ident , & syn:: Field ) ] ,
169
170
) -> ElasticMetadataMethods {
@@ -190,7 +191,7 @@ fn get_doc_ty_impl_block(
190
191
match get_method_from_struct ( item, "ty" ) {
191
192
Some ( MethodFromStruct :: Literal ( name) ) => ( name, true ) ,
192
193
Some ( MethodFromStruct :: Expr ( method) ) => ( quote ! ( #method( self ) ) , false ) ,
193
- _ => ( quote ! ( "doc" ) , true ) ,
194
+ _ => ( quote ! ( #crate_root :: derive :: DEFAULT_DOC_TYPE ) , true ) ,
194
195
}
195
196
} ;
196
197
@@ -224,7 +225,7 @@ fn get_doc_ty_impl_block(
224
225
ref ty,
225
226
ty_is_static,
226
227
ref id,
227
- } = get_doc_type_methods ( item, fields) ;
228
+ } = get_doc_type_methods ( crate_root , item, fields) ;
228
229
229
230
let doc_ty = & item. ident ;
230
231
You can’t perform that action at this time.
0 commit comments