package msgio
Import Path
github.com/libp2p/go-msgio (on go.dev)
Dependency Relation
imports 7 packages, and imported by 3 packages
Package-Level Type Names (total 7)
B bytes.Buffer
M sync.Mutex
W io.Writer
(*LimitedWriter) Flush() error
(*LimitedWriter) Write(buf []byte) (n int, err error)
*LimitedWriter : github.com/apache/thrift/lib/go/thrift.Flusher
*LimitedWriter : github.com/miekg/dns.Writer
*LimitedWriter : internal/bisect.Writer
*LimitedWriter : io.Writer
func NewLimitedWriter(w io.Writer) *LimitedWriter
ReadCloser combines a Reader and Closer.
( ReadCloser) Close() error
NextMsgLen returns the length of the next (peeked) message. Does
not destroy the message or have other adverse effects
Read reads the next message from the Reader.
The client must pass a buffer large enough, or io.ErrShortBuffer will be
returned.
ReadMsg reads the next message from the Reader.
Uses a pool.BufferPool internally to reuse buffers. User may call
ReleaseMsg(msg) to signal a buffer can be reused.
ReleaseMsg signals a buffer can be reused.
ReadWriteCloser (interface)
ReadCloser : Reader
ReadCloser : github.com/prometheus/common/expfmt.Closer
ReadCloser : io.Closer
ReadCloser : io.ReadCloser
ReadCloser : io.Reader
func NewReader(r io.Reader) ReadCloser
func NewReaderSize(r io.Reader, maxMessageSize int) ReadCloser
func NewReaderSizeWithPool(r io.Reader, maxMessageSize int, p *pool.BufferPool) ReadCloser
func NewReaderWithPool(r io.Reader, p *pool.BufferPool) ReadCloser
func NewVarintReader(r io.Reader) ReadCloser
func NewVarintReaderSize(r io.Reader, maxMessageSize int) ReadCloser
func NewVarintReaderSizeWithPool(r io.Reader, maxMessageSize int, p *pool.BufferPool) ReadCloser
func NewVarintReaderWithPool(r io.Reader, p *pool.BufferPool) ReadCloser
Reader is the msgio Reader interface. It reads len-framed messages.
NextMsgLen returns the length of the next (peeked) message. Does
not destroy the message or have other adverse effects
Read reads the next message from the Reader.
The client must pass a buffer large enough, or io.ErrShortBuffer will be
returned.
ReadMsg reads the next message from the Reader.
Uses a pool.BufferPool internally to reuse buffers. User may call
ReleaseMsg(msg) to signal a buffer can be reused.
ReleaseMsg signals a buffer can be reused.
ReadCloser (interface)
ReadWriteCloser (interface)
ReadWriter (interface)
Reader : io.Reader
func Combine(w Writer, r Reader) ReadWriteCloser
ReadWriteCloser combines a Reader, a Writer, and Closer.
( ReadWriteCloser) Close() error
NextMsgLen returns the length of the next (peeked) message. Does
not destroy the message or have other adverse effects
Read reads the next message from the Reader.
The client must pass a buffer large enough, or io.ErrShortBuffer will be
returned.
ReadMsg reads the next message from the Reader.
Uses a pool.BufferPool internally to reuse buffers. User may call
ReleaseMsg(msg) to signal a buffer can be reused.
ReleaseMsg signals a buffer can be reused.
Write writes passed in buffer as a single message.
WriteMsg writes the msg in the passed in buffer.
ReadWriteCloser : ReadCloser
ReadWriteCloser : Reader
ReadWriteCloser : ReadWriter
ReadWriteCloser : WriteCloser
ReadWriteCloser : Writer
ReadWriteCloser : github.com/miekg/dns.Writer
ReadWriteCloser : github.com/pion/stun.Connection
ReadWriteCloser : github.com/pion/stun/v3.Connection
ReadWriteCloser : github.com/prometheus/common/expfmt.Closer
ReadWriteCloser : internal/bisect.Writer
ReadWriteCloser : io.Closer
ReadWriteCloser : io.ReadCloser
ReadWriteCloser : io.Reader
ReadWriteCloser : io.ReadWriteCloser
ReadWriteCloser : io.ReadWriter
ReadWriteCloser : io.WriteCloser
ReadWriteCloser : io.Writer
func Combine(w Writer, r Reader) ReadWriteCloser
func NewReadWriter(rw io.ReadWriter) ReadWriteCloser
ReadWriter combines a Reader and Writer.
NextMsgLen returns the length of the next (peeked) message. Does
not destroy the message or have other adverse effects
Read reads the next message from the Reader.
The client must pass a buffer large enough, or io.ErrShortBuffer will be
returned.
ReadMsg reads the next message from the Reader.
Uses a pool.BufferPool internally to reuse buffers. User may call
ReleaseMsg(msg) to signal a buffer can be reused.
ReleaseMsg signals a buffer can be reused.
Write writes passed in buffer as a single message.
WriteMsg writes the msg in the passed in buffer.
ReadWriteCloser (interface)
ReadWriter : Reader
ReadWriter : Writer
ReadWriter : github.com/miekg/dns.Writer
ReadWriter : internal/bisect.Writer
ReadWriter : io.Reader
ReadWriter : io.ReadWriter
ReadWriter : io.Writer
WriteCloser is a Writer + Closer interface. Like in `golang/pkg/io`
( WriteCloser) Close() error
Write writes passed in buffer as a single message.
WriteMsg writes the msg in the passed in buffer.
ReadWriteCloser (interface)
WriteCloser : Writer
WriteCloser : github.com/miekg/dns.Writer
WriteCloser : github.com/prometheus/common/expfmt.Closer
WriteCloser : internal/bisect.Writer
WriteCloser : io.Closer
WriteCloser : io.WriteCloser
WriteCloser : io.Writer
func NewVarintWriter(w io.Writer) WriteCloser
func NewVarintWriterWithPool(w io.Writer, p *pool.BufferPool) WriteCloser
func NewWriter(w io.Writer) WriteCloser
func NewWriterWithPool(w io.Writer, p *pool.BufferPool) WriteCloser
Writer is the msgio Writer interface. It writes len-framed messages.
Write writes passed in buffer as a single message.
WriteMsg writes the msg in the passed in buffer.
ReadWriteCloser (interface)
ReadWriter (interface)
WriteCloser (interface)
Writer : github.com/miekg/dns.Writer
Writer : internal/bisect.Writer
Writer : io.Writer
func Combine(w Writer, r Reader) ReadWriteCloser
Package-Level Functions (total 18)
Combine wraps a pair of msgio.Writer and msgio.Reader with a msgio.ReadWriter.
LimitedReader wraps an io.Reader with a msgio framed reader. The LimitedReader
will return a reader which will io.EOF when the msg length is done.
LimitedWriter wraps an io.Writer with a msgio framed writer. It is the inverse
of LimitedReader: it will buffer all writes until "Flush" is called. When Flush
is called, it will write the size of the buffer first, flush the buffer, reset
the buffer, and begin accept more incoming writes.
NewReader wraps an io.Reader with a msgio framed reader. The msgio.Reader
will read whole messages at a time (using the length). Assumes an equivalent
writer on the other side.
NewReaderSize is equivalent to NewReader but allows one to
specify a max message size.
NewReaderWithPool is the same as NewReader but allows one to specify a buffer
pool and a max message size.
NewReaderWithPool is the same as NewReader but allows one to specify a buffer
pool.
NewReadWriter wraps an io.ReadWriter with a msgio.ReadWriter. Writing
and Reading will be appropriately framed.
NewVarintReader wraps an io.Reader with a varint msgio framed reader.
The msgio.Reader will read whole messages at a time (using the length).
Varints read according to https://golang.org/pkg/encoding/binary/#ReadUvarint
Assumes an equivalent writer on the other side.
NewVarintReaderSize is equivalent to NewVarintReader but allows one to
specify a max message size.
NewVarintReaderWithPool is the same as NewVarintReader but allows one to
specify a buffer pool and a max message size.
NewVarintReaderWithPool is the same as NewVarintReader but allows one to
specify a buffer pool.
NewVarintWriter wraps an io.Writer with a varint msgio framed writer.
The msgio.Writer will write the length prefix of every message written
as a varint, using https://golang.org/pkg/encoding/binary/#PutUvarint
func NewVarintWriterWithPool(w io.Writer, p *pool.BufferPool) WriteCloser
NewWriter wraps an io.Writer with a msgio framed writer. The msgio.Writer
will write the length prefix of every message written.
NewWriterWithPool is identical to NewWriter but allows the user to pass a
custom buffer pool.
ReadLen reads a length from the given reader.
if buf is non-nil, it reuses the buffer. Ex:
l, err := ReadLen(r, nil)
_, err := ReadLen(r, buf)
WriteLen writes a length to the given writer.
Package-Level Variables (total 2)
ErrMsgTooLarge is returned when the message length is exessive
NBO is NetworkByteOrder
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |