framer

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2023 License: BSD-3-Clause Imports: 5 Imported by: 4

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

View Source
var (
	ErrLargerThan3ByteUInt = verror.NewIDAction("v.io/x/ref/runtime/protocols/lib/framer.LargerThan3ByteUInt", verror.NoRetry)
)

Functions

func ErrorfLargerThan3ByteUInt added in v0.1.10

func ErrorfLargerThan3ByteUInt(ctx *context.T, format string) error

ErrorfLargerThan3ByteUInt calls ErrLargerThan3ByteUInt.Errorf with the supplied arguments.

func MessageLargerThan3ByteUInt added in v0.1.10

func MessageLargerThan3ByteUInt(ctx *context.T, message string) error

MessageLargerThan3ByteUInt calls ErrLargerThan3ByteUInt.Message with the supplied arguments.

func ParamsErrLargerThan3ByteUInt added in v0.1.10

func ParamsErrLargerThan3ByteUInt(argumentError error) (verrorComponent string, verrorOperation string, returnErr error)

ParamsErrLargerThan3ByteUInt extracts the expected parameters from the error's ParameterList.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL