MappingType

Trait MappingType 

Source
pub trait MappingType {
    // Required method
    fn field_type() -> &'static str;

    // Provided methods
    fn fields() -> Map<String, Value> { ... }
    fn mapping() -> Map<String, Value> { ... }
}
Expand description

Trait for types that can be mapped to Elasticsearch field types.

This trait is implemented for all Rust primitive types and can be implemented for custom types. It’s automatically implemented by the #[derive(Document)] macro for structs.

You generally don’t need to implement this trait manually unless you’re adding support for custom types.

Required Methods§

Source

fn field_type() -> &'static str

Returns the Elasticsearch field type name.

Examples: "text", "long", "boolean", "object", etc.

Provided Methods§

Source

fn fields() -> Map<String, Value>

Returns the properties map for complex types (objects).

For scalar types (like String, i32), this returns an empty map. For object types, this returns the field definitions.

Source

fn mapping() -> Map<String, Value>

Generates the complete mapping definition for this type.

This includes the "type" field and optionally a "properties" field for nested objects.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl MappingType for bool

Source§

fn field_type() -> &'static str

Source§

impl MappingType for f32

Source§

fn field_type() -> &'static str

Source§

impl MappingType for f64

Source§

fn field_type() -> &'static str

Source§

impl MappingType for i8

Source§

fn field_type() -> &'static str

Source§

impl MappingType for i16

Source§

fn field_type() -> &'static str

Source§

impl MappingType for i32

Source§

fn field_type() -> &'static str

Source§

impl MappingType for i64

Source§

fn field_type() -> &'static str

Source§

impl MappingType for u8

Source§

fn field_type() -> &'static str

Source§

impl MappingType for u16

Source§

fn field_type() -> &'static str

Source§

impl MappingType for u32

Source§

fn field_type() -> &'static str

Source§

impl MappingType for u64

Source§

fn field_type() -> &'static str

Source§

impl MappingType for String

Source§

fn field_type() -> &'static str

Source§

impl<T: MappingType> MappingType for Option<T>

Source§

fn field_type() -> &'static str

Source§

impl<T: MappingType> MappingType for Vec<T>

Implementors§