File tree 3 files changed +22
-4
lines changed
3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -18,22 +18,34 @@ use serde;
18
18
/// # Links
19
19
///
20
20
/// - [Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html)
21
- pub trait ElasticDataType < T : ElasticMapping < F > , F > { }
21
+ pub trait ElasticDataType < T : ElasticMapping < F > , F > : TypeEllision { }
22
+
23
+ #[ doc( hidden) ]
24
+ pub enum TypeEllisionKind {
25
+ Explicit ,
26
+ Ellided
27
+ }
28
+ #[ doc( hidden) ]
29
+ pub trait TypeEllision {
30
+ fn get_ellision ( ) -> TypeEllisionKind {
31
+ TypeEllisionKind :: Explicit
32
+ }
33
+ }
22
34
23
35
/// The base requirements for mapping an Elasticsearch data type.
24
36
///
25
37
/// Each type has its own implementing structures with extra type-specific mapping parameters.
26
38
pub trait ElasticMapping < F = ( ) >
27
39
where Self : Default + serde:: Serialize {
28
- /// The serialisation visitor used to inspect this mapping.
40
+ # [ doc ( hidden ) ]
29
41
type Visitor : serde:: ser:: MapVisitor + Default ;
30
42
31
43
/// An optional associated type that mappings may need.
32
44
///
33
45
/// For example; the `Format` trait on `DateTime`.
34
46
type Format = F ;
35
47
36
- /// Gets an instance of the `Visitor` for serialisation.
48
+ # [ doc ( hidden ) ]
37
49
fn get_visitor ( ) -> Self :: Visitor {
38
50
Self :: Visitor :: default ( )
39
51
}
Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ fn can_access_mapping_for_auto_impls() {
73
73
assert_eq ! ( "object" , MappingDispatch :: <i32 >:: map( & ty) ) ;
74
74
}
75
75
76
+ #[ test]
77
+ fn can_access_type_ellision_for_mappings ( ) {
78
+
79
+ }
80
+
76
81
#[ test]
77
82
fn serialise_mapping_null ( ) {
78
83
let mapping = NullMapping ;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ struct MyType {
17
17
pub num : i32
18
18
}
19
19
20
+ //All this should be derived
20
21
impl < ' a > ElasticDataType < MyTypeMapping < ' a > , ( ) > for MyType { }
21
22
22
23
//The mapping for our type
@@ -62,7 +63,7 @@ impl <'a> serde::Serialize for MyTypeMapping<'a> {
62
63
fn serialize < S > ( & self , serializer : & mut S ) -> Result < ( ) , S :: Error >
63
64
where S : serde:: Serializer
64
65
{
65
- serializer. serialize_struct ( "mapping " , MyTypeMappingVisitor :: default ( ) )
66
+ serializer. serialize_struct ( "properties " , MyTypeMappingVisitor :: default ( ) )
66
67
}
67
68
}
68
69
You can’t perform that action at this time.
0 commit comments