Skip to content

proposal: io,net: add WriteMany interface #68625

@Jorropo

Description

@Jorropo

Proposal Details

This proposal aims at making a user-implementable version of net.Buffers.

Add a new interface to io and implement it on net.* which implement net.buffersWriter:

type ManyWriter interface {
 // WriteMany has the same semantics as appending the buffers back to back into one buffer and calling [Writer.Write] method,
 // but it allows to remove the need to allocate and copy all the buffers in one contiguous memory region.
 // The implementation cannot write to any of the passed buffer or buffers slice.
 WriteMany(...[]byte) (n int64, err error)
}

note: this return int64 because it would be easy to build let's say 16GiB buffer on a 32bits pointer architecture by having the byte arrays alias each other.

(*net.Buffers).WriteTo would also check if the underlying implementation supports io.ManyWriter as well as net.buffersWriter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions