Documentation ¶
Overview ¶
Package framer provides the ability to wrap a network connection (or any io.ReadWriteCloser) with framing that consists of a 3-byte length followed by data of that length.
This file was auto-generated by the vanadium vdl tool. Package: framer
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrLargerThan3ByteUInt = verror.NewIDAction("v.io/x/ref/runtime/protocols/lib/framer.LargerThan3ByteUInt", verror.NoRetry)
)
Functions ¶
func ErrorfLargerThan3ByteUInt ¶ added in v0.1.10
ErrorfLargerThan3ByteUInt calls ErrLargerThan3ByteUInt.Errorf with the supplied arguments.
func MessageLargerThan3ByteUInt ¶ added in v0.1.10
MessageLargerThan3ByteUInt calls ErrLargerThan3ByteUInt.Message with the supplied arguments.
Types ¶
type T ¶ added in v0.2.0
type T interface { // MsgReadWriteCloser reads/writes frames to the underlying stream. flow.MsgReadWriteCloser // ReadWriter provides raw, unframed, access to the underlying stream, // that is messages are written/read from it without notion of a frame. io.ReadWriter // FrameHeaderSize returns the size, in bytes, of the frame header. FrameHeaderSize() int // PutSize encodes the message size into FrameHeaderSize bytes at // the head of dst (ie. dst[0:FrameHeaderSize()]) PutSize(dst []byte, msgSize int) error // GetSize retrieves the encoded message size from src[0:FrameHeaderSize()] GetSize(src []byte) int }
T represents the interface to a framer, see New, for a more complete explanation.
func New ¶
func New(c io.ReadWriteCloser) T
New creates a new instance of T that implements 'framing' over a raw connection via the flow.MsgReadWriteCloser methods. It also provides direct access (without framing) via the io.ReadWriter methods, which in conjunction with the SizeBytes, PutSize and Size methods can be used to send pre-framed messages to reduce the number of system calls and copying that is otherwise required. The framer may issue multiple writes to the underlying connection for a single message. For smaller messages it will copy the data into a single buffer and issue a single write. This combinded approach ensures that the framer has a fixed and known memory overhead.