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

Add a "mid-level" API #20

Open
SimonSapin opened this issue Nov 26, 2013 · 0 comments
Open

Add a "mid-level" API #20

SimonSapin opened this issue Nov 26, 2013 · 0 comments
Milestone

Comments

@SimonSapin
Copy link
Collaborator

Currently the API provides "high-level" and "low-level" methods. The former takes a single string/vector in memory with an error handling mechanism, and returns another string/vector:

fn decode(&'static Encoding, input: &[u8], trap: Trap) -> Result<~str,SendStr>;

The latter allows incremental processing of the input (eg. as it is downloaded from the network), but leaves error handling to the user:

fn decoder(&'static Encoding) -> ~Decoder;
fn raw_feed(&mut Decoder, input: &[u8], output: &mut StringWriter) -> (uint, Option<CodecError>);
fn raw_finish(&mut Decoder, output: &mut StringWriter) -> Option<CodecError>;

It would be useful to also have an intermediate that does error handling but allows incremental processing, eg:

fn decoder(&'static Encoding, trap: Trap) -> ~Decoder;
fn feed(&mut Decoder, input: &[u8], output: &mut StringWriter) -> Option<SendStr>;
fn finish(&mut Decoder, output: &mut StringWriter) -> Option<SendStr>;

(trap is part of the decoder, because there is no reason to change it mid-stream.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants