Elasticsearch Date Format Codegen
Compile-time code generation for Elasticsearch type implementations.
Usage
This crate is on crates.io.
There are two ways to reference elastic_date_macros
in your projects, depending on whether you're on
the stable
/beta
or nightly
channels.
Stable
To get started, add elastic_date_macros
to your Cargo.toml
:
[dependencies]
elastic_date_macros = "*"
And reference it in your crate root:
#[macro_use]
extern crate elastic_date_macros;
Nightly
To get started, add elastic_date_macros
to your Cargo.toml
:
[dependencies]
elastic_date_macros = { version = "*", features = "nightly" }
And reference it in your crate root:
#![feature(plugin)]
#![plugin(elastic_date_macros)]
If you're on the nightly
channel, it's better to use the above plugin
version with the nightly
feature because the conversion of formats from strings to Items takes place at compile-time instead of runtime,
saving precious runtime cycles.
This crate provides the utility macro date_fmt
which can be used to build a Vec<chrono::Item>
from either an elasticsearch or chrono date format.
//A chrono-based format
let items = date_fmt!("%Y%m%dT%H%M%S%.3fZ");
//An elasticsearch-based format
let items = date_fmt!("yyyyMMddTHHmmss.SSSZ");