message

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package message provides the NETCONF message layer.

A Session uses the Splitter type along with Reader and Writer to provide per-message io.Reader and io.WriteCloser objects.

Index

Constants

This section is empty.

Variables

View Source
var ErrEndOfStream = errors.New("end of stream")

ErrEndOfStream indicates the transport stream has ended. This is somewhat equivalent to io.EOF, in that it indicates no more data can be read from the underlying transport due to an EOF on said transport.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	D     *transport.Reader
	OnEOF func()
	// contains filtered or unexported fields
}

Decoder is a NETCONF message reader, implementing io.ReadCloser.

D must point to an initialized *transport.Reader, while OnEOF must be a non-nil function, called at end of stream, when the underlying transport sees EOF.

func (*Decoder) Close

func (d *Decoder) Close() error

Close closes the message. Further reads to this channel will return EOF.

func (*Decoder) Read

func (d *Decoder) Read(p []byte) (n int, err error)

Read reads data from the underlying transport into, decoding the transport framing and populating p with uncooked data, implementing io.Reader.

type Encoder

type Encoder struct {
	E        *transport.Writer
	OnClosed func()
	// contains filtered or unexported fields
}

Encoder is a NETCONF message encoder, implementing io.WriteCloser

func (*Encoder) Close

func (e *Encoder) Close() (err error)

Close closes the message, causing the end of message token to be written to the underlying transport if any data had been written to this channel.

func (*Encoder) Write

func (e *Encoder) Write(b []byte) (int, error)

Write writes the cooked encoding of b in the current framing mode to the underlying transport, implementing io.Writer.

type Splitter

type Splitter struct {
	R *transport.Reader
	W *transport.Writer
	// contains filtered or unexported fields
}

Splitter manages the NETCONF transport session for the message layer.

Its task is to split the session up into a series of NETCONF messages. A NETCONF message is a complete XML document. Normally, a single NETCONF message is followed by the transport end-of-message marker. If the session has negotiated pipelining support, multiple NETCONF messages (typically multiple <rpc> or <rpc-reply> elemenets) may be exchanged before the transport end-of-message marker is exchanged.

The Splitter provides access to the current message Decoder and Encoder. The Reader will return EOF when the end-of-message marker is received, while the Writer sends the end-of-message marker when closed.

func (*Splitter) FinishReader

func (s *Splitter) FinishReader()

FinishReader emits a new reader on the next call(s) to Reader

func (*Splitter) FinishWriter

func (s *Splitter) FinishWriter()

FinishWriter emits a new writer on the next call(s) to Writer

func (*Splitter) Reader

func (s *Splitter) Reader() *Decoder

Reader returns the current message's reader (implementing io.Reader), or creates a new message reader and returns that.

func (*Splitter) Writer

func (s *Splitter) Writer() *Encoder

Writer returns the current message's writer (implementing io.WriteCloser)

Jump to

Keyboard shortcuts

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