Skip to content

1. &io.Data may not be a good abstraction 2. Writer interface #201

Description

@bobzhang
  1. From what I can tell, it only supports 3 kinds of data: Bytes, String and Json where String and Json are used most. It was introduced to allow some overloading so that
@http.post("url", data)
@http.post("url", { "xx" : "json"})

but this does not work in practice so that we have to write @http.post("url", ({"xx" : "json"} : Json)) which is not better than
@http.post_json("url", {"x" : "data"}) when it could be more efficient or more redable.

it looks to me that either

@http.post("url", String("..."))
@http.post("url", Bytes("..."))
@http.post("url", Json("..."))

or

@http.post("url","...")
@http.post_bytes("url","...")
@http.post_json("url", "...")

they are both more readable and can be more efficient than the current interface
2.

pub(open) trait Writer {
async write_once(Self, Bytes, offset~ : Int, len~ : Int) -> Int // --> async write_once(Self, BytesView) -> Int
async write(Self, &Data) -> Unit = _
async write_reader(Self, &Reader) -> Unit = _
#deprecated("use write instead", skip_current_package=true)
async write_string(Self, StringView, encoding~ : Encoding) -> Unit = _
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions