Trait opensearch::http::request::Body

source ·
pub trait Body {
    // Required method
    fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>;

    // Provided method
    fn bytes(&self) -> Option<Bytes> { ... }
}
Expand description

Body of an API call.

Some Elasticsearch APIs accept a body as part of the API call. Most APIs expect JSON, however, there are some APIs that expect newline-delimited JSON (NDJSON). The Body trait allows modelling different API body implementations.

Required Methods§

source

fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>

Write to a buffer that will be written to the request stream

Provided Methods§

source

fn bytes(&self) -> Option<Bytes>

An existing immutable buffer that can be used to avoid having to write to another buffer that will then be written to the request stream.

If this method returns Some, the bytes must be the same as those that would be written by Body::write.

Implementations on Foreign Types§

source§

impl Body for ()

source§

fn write(&self, _bytes: &mut BytesMut) -> Result<(), Error>

source§

impl Body for String

source§

fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>

source§

impl Body for Vec<u8>

source§

fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>

source§

impl Body for Bytes

source§

fn bytes(&self) -> Option<Bytes>

source§

fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>

source§

impl Body for BytesMut

source§

fn bytes(&self) -> Option<Bytes>

source§

fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>

source§

impl<'a> Body for &'a str

source§

fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>

source§

impl<'a> Body for &'a [u8]

source§

fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>

source§

impl<'a, B> Body for &'a B
where B: Body + ?Sized,

source§

fn bytes(&self) -> Option<Bytes>

source§

fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>

Implementors§

source§

impl Body for BulkOperations

source§

impl<B> Body for BulkOperation<B>
where B: Serialize,

source§

impl<T> Body for JsonBody<T>
where T: Serialize,

source§

impl<T> Body for NdBody<T>
where T: Body,