Skip to content

Why implement Buffer and Memory? #125

Description

@warrenalphonso

Hey I've just been poking around this package and it seems overly complex. Can someone more familiar with it make sure I haven't just missed Chesterton's fence 😛 Happy to work on this if people agree it makes sense

AFAICT, TranscodingStream manages an input and output Buffer; data is read from the input stream into the input Buffer. This is passed to a codec via Memory (which is just an abstraction over the "used" and "free" parts of a Buffer). The codec writes to the output Buffer, and that's given to the user via an output stream when requested.

  • Remove Memory. I can't figure out why this is useful, aside from just making things slightly easier for downstream codecs that are C-based and need pointers. If that's the case, we could views instead.
  • Remove Buffer. We really don't need our own implementation; I think IOBuffer should work. Fundamentally, we just want to load data from the input stream into some input array, let a codec convert part of that to an output array, and send it to the user via a stream.

Less importantly:

  • Remove Error. Why not just try/catch instead of passing yet another variable around as state?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions