The body T is then passed to reqwest's json() fn to serialize as JSON.
Both String and Vec<u8>, and their reference/slice counterparts have Serialize impls, but the resulting request body is unexpected/not that useful; For String, the body will be a literal string value enclosed in double quotes, whilst Vec<u8> will be a JSON array of numbers.
What is probably more useful is to allow a consumer to pass a JSON string literal or JSON bytes to the body method, and write these using reqwest's body() fn.
The current
body
associated fn on each builder struct expects aT
that implements theSerialize
trait. For example, forSearch
The body
T
is then passed to reqwest'sjson()
fn to serialize as JSON.Both
String
andVec<u8>
, and their reference/slice counterparts haveSerialize
impls, but the resulting request body is unexpected/not that useful; ForString
, the body will be a literal string value enclosed in double quotes, whilstVec<u8>
will be a JSON array of numbers.What is probably more useful is to allow a consumer to pass a JSON string literal or JSON bytes to the
body
method, and write these using reqwest'sbody()
fn.