Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[simple-api] Add string value reader & writer methods #54

Closed
Marcono1234 opened this issue Feb 28, 2024 · 0 comments
Closed

[simple-api] Add string value reader & writer methods #54

Marcono1234 opened this issue Feb 28, 2024 · 0 comments
Labels
enhancement New feature or request feature:simple-api Issue or pull related to the "Simple API"

Comments

@Marcono1234
Copy link
Owner

Marcono1234 commented Feb 28, 2024

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 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.

Alternatives / workarounds

Use the Advanced API

@Marcono1234 Marcono1234 added enhancement New feature or request feature:simple-api Issue or pull related to the "Simple API" labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature:simple-api Issue or pull related to the "Simple API"
Projects
None yet
Development

No branches or pull requests

1 participant