Documentation ¶
Index ¶
Constants ¶
const (
// DecoderMinScannerBufferSize is the scanner buffer size floor.
DecoderMinScannerBufferSize = 20
)
Variables ¶
var ( // ErrZeroChunks is a protocol error indicating that no chunk was // seen prior to the end-of-chunks token. ErrZeroChunks = errors.New("end-of-chunks seen prior to chunk") // ErrChunkSizeInvalid is a protocol error indicating that a chunk // frame introduction was seen, but chunk-size decoding failed. ErrChunkSizeInvalid = errors.New("no valid chunk-size detected") // ErrChunkSizeTokenTooLong is a protocol error indicating a // valid chunk-size token start was seen, but that the chunk-size // token was longer than that necessary to store the maximum // permitted chunk size "4294967295". ErrChunkSizeTokenTooLong = errors.New("token too long") // ErrChunkSizeTooLarge is a protocol error indicating that the // chunk-size decoded exceeds the limit stated in RFC6242. ErrChunkSizeTooLarge = errors.New("chunk size larger than maximum (4294967295)") )
Functions ¶
func SetChunkedFraming ¶
func SetChunkedFraming(objects ...interface{})
SetChunkedFraming enables chunked framing mode on any non-nil *Decoder and *Encoder objects passed to it.
Types ¶
type Decoder ¶
type Decoder struct { // Input is the input source for the Decoder. The input stream // must consist of RFC6242 encoded data according to the current // Framer. Input io.Reader // contains filtered or unexported fields }
Decoder is an RFC6242 transport framing decoder filter.
Decoder operates as an inline filter, taking a io.Reader as input and providing io.Reader.
Decoder is not safe for concurrent use.
func NewDecoder ¶
func NewDecoder(input io.Reader, options ...DecoderOption) *Decoder
NewDecoder creates a new RFC6242 transport framing decoder reading from input, configured with any options provided.
type DecoderOption ¶
type DecoderOption func(*Decoder)
DecoderOption is a constructor option function for the Decoder type.
func WithFramer ¶
func WithFramer(f FramerFn) DecoderOption
WithFramer sets the Decoder's initial Framer.
func WithScannerBufferSize ¶
func WithScannerBufferSize(bytes int) DecoderOption
WithScannerBufferSize configures the buffer size of the bufio.Scanner used by the decoder to scan input tokens. If bytes is smaller than the constant DecoderMinScannerBufferSize, the buffer size will be set to DecoderMinScannerBufferSize.
type Encoder ¶
type Encoder struct { // Output is the underlying Writer to receive encoded output Output io.Writer // ChunkedFraming sets whether the next call to Write should use // chunked-message framing (true) or end-of-message framing (false) ChunkedFraming bool // MaxChunkSize is the maximum size of chunks the encoder will Encode. If // zero, the Encoder places no artificial ceiling on the chunk size. MaxChunkSize uint32 }
Encoder is a filtering writer. By default it acts as a pass through writer. If chunked mode is enabled (see SetChunkedFramingMode), input to Write calls is chunked and the RFC6242 chunked encoding output written to the underlying writer.
func NewEncoder ¶
func NewEncoder(output io.Writer, opts ...EncoderOption) *Encoder
NewEncoder returns a new RFC6242 transport encoding writer with underlying writer output, configured with any options provided.
func (*Encoder) EndOfMessage ¶
EndOfMessage must be called after each conceptual message (or XML document) is written to the Encoder. It writes the appropriate NETCONF message ending, either "]]>]]>" or if chunked framing is enabled, "\n##\n".
type EncoderOption ¶
type EncoderOption func(*Encoder)
EncoderOption is a consturctor option function for the Encoder type.
func WithMaximumChunkSize ¶
func WithMaximumChunkSize(size uint32) EncoderOption
WithMaximumChunkSize sets an upper bound on the chunk size used when writing data to an Encoder. If 0 is passed, the upper bound reverts to the maximum chunk size permitted by RFC6242.