elastic / elasticsearch-rs

Official Elasticsearch Rust Client
https://www.elastic.co/guide/en/elasticsearch/client/rust-api/current/index.html
Apache License 2.0
705 stars 72 forks source link

Add Body trait to model different API body implementations #32

Closed russcam closed 4 years ago

russcam commented 4 years ago

This PR adds a Body trait to allow modelling of different API body implementations. All APIs accept JSON bodies, except bulk, msearch, msearchtemplate and ML post data, which accept newline delimited JSON (ndjson).

Provide implementations of Body for both json and ndjson. Serde library is not able to serialize to ndjson because an impl cannot generalize for all Serialize impls. To be able to serialize ndjson requires access to the buffer, allowing a Body impl to control how it is written to the buffer.

Closes #31