Currently the Simple API only supports reading JSON string values as str / String. For larger string values it might useful if they could be read using a Read and written using a Write, similar to what the Advanced API offers with JsonReader::next_string_reader and JsonWriter::string_value_writer.
Enhancement description
Add methods to the Simple API which are similar and delegate to the Advanced API. They should have an FnOnce -> T as parameter which takes a Read / Write (respectively custom struct) as argument. For example:
ValueReader::read_string_with_reader
Implicitly consumes any remaining bytes which the function did not consume
ValueWriter::write_string_with_writer
Implicitly finishes the value once the function returns
(or similar names)
Should probably not expose the traits from the Advanced API (currently only JsonWriter::string_value_writer has a custom trait) since they provide functionality which is redundant or might interfere with the Simple API behavior, e.g. StringValueWriter::finish_value, and because their documentation might be misleading for the Simple API.
The documentation for these methods should then probably have the same notes about reader and writer errors as the Advanced API, namely that reading / writing should be stopped even if Read or Write might permit retrying normally.
Problem solved by the enhancement
Currently the Simple API only supports reading JSON string values as
str
/String
. For larger string values it might useful if they could be read using aRead
and written using aWrite
, similar to what the Advanced API offers withJsonReader::next_string_reader
andJsonWriter::string_value_writer
.Enhancement description
Add methods to the Simple API which are similar and delegate to the Advanced API. They should have an
FnOnce -> T
as parameter which takes aRead
/Write
(respectively custom struct) as argument. For example:ValueReader::read_string_with_reader
Implicitly consumes any remaining bytes which the function did not consumeValueWriter::write_string_with_writer
Implicitly finishes the value once the function returns(or similar names)
Should probably not expose the traits from the Advanced API (currently only
JsonWriter::string_value_writer
has a custom trait) since they provide functionality which is redundant or might interfere with the Simple API behavior, e.g.StringValueWriter::finish_value
, and because their documentation might be misleading for the Simple API.The documentation for these methods should then probably have the same notes about reader and writer errors as the Advanced API, namely that reading / writing should be stopped even if
Read
orWrite
might permit retrying normally.Alternatives / workarounds
Use the Advanced API