encoding

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

エンコード層

エンコード層では、ワイヤ層のメッセージの シリアライズ/デシリアライズ方法 を定義します。

エンコード層のインターフェース

エンコード層が実装すべきインターフェースについては、ワイヤ層の Encoding インターフェース をご参照ください。

対応エンコード一覧

Documentation

Overview

Package encoding は、 iSCP で使用するエンコーディングをまとめたパッケージです。

Index

Constants

View Source
const (
	B  Size = 1
	KB      = B * 1000
	MB      = KB * 1000
	GB      = MB * 1000
	TB      = GB * 1000
	PB      = TB * 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentType

type ContentType string

ContentType は、エンコードされたメッセージの形式を表します。

const (
	// ContentTypeBinary は、バイナリ形式の EncodingContentType を表します。
	ContentTypeBinary ContentType = "binary"

	// ContentTypeText は、テキスト形式の EncodingContentType を表します。
	ContentTypeText ContentType = "text"
)

type Encoding

type Encoding interface {
	// EncodeTo は、 iSCP のメッセージをバイナリへエンコードし、与えられた Writer に書き込みます。
	EncodeTo(io.Writer, message.Message) (int, error)

	// DecodeFrom は、与えられた Reader から読みだしたバイナリを、 iSCP のメッセージへデコードします。
	DecodeFrom(io.Reader) (int, message.Message, error)

	// ContentType は、このエンコーディングの ContentType を返します。
	ContentType() ContentType

	// Name は、このエンコーディングの識別名を返します。
	Name() Name
}

Encoding は、 iSCP のエンコード層を抽象化したインターフェースです。

type Name

type Name string

Name は、エンコーディングの識別名を表します。

const (
	// NameJSON は、 JSON 形式のエンコーディングを表す名称です。
	NameJSON Name = Name(transport.EncodingNameJSON)

	// NameProtobuf は、 Protocol Buffers 形式のエンコーディングを表す名称です。
	NameProtobuf Name = Name(transport.EncodingNameProtobuf)
)

type Size

type Size int64

Sizeは、バイトサイズの単位です。

func (Size) String

func (s Size) String() string

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transportは、エンコーディングされたメッセージを伝送するトランスポートです。

エンコーディングされたメッセージをトランスポートから読み込んだり、トランスポートへ書き込んだりして使用します。

func NewTransport

func NewTransport(c *TransportConfig) *Transport

NewTransportは、エンコーディングされたメッセージを伝送するトランスポートを生成します。

func (*Transport) Close

func (e *Transport) Close() error

Closeは、トランスポートを閉じます。

func (*Transport) Read

func (c *Transport) Read() (message.Message, error)

Readは、トランスポートからメッセージを読み込みます。

func (*Transport) RxMessageCounterValue

func (c *Transport) RxMessageCounterValue() uint64

RxMessageCounterValueは、トランスポートから読み込んだメッセージの数を返却します。

func (*Transport) TxMessageCounterValue

func (c *Transport) TxMessageCounterValue() uint64

TxMessageCounterValueは、トランスポートへ書き込んだメッセージの数を返却します。

func (*Transport) Write

func (c *Transport) Write(message message.Message) error

Writeは、トランスポートへメッセージを書き出します。

type TransportConfig

type TransportConfig struct {
	Transport      transport.ReadWriter
	Encoding       Encoding
	MaxMessageSize Size
}

TransportConfigは、エンコーディングされたメッセージを伝送するトランスポートについての設定です。

Directories

Path Synopsis
Package encodingmock is a generated GoMock package.
Package encodingmock is a generated GoMock package.
Package json は、 JSON フォーマットを使用したエンコーディングを提供するパッケージです。
Package json は、 JSON フォーマットを使用したエンコーディングを提供するパッケージです。
Package protobuf は、 Protocol Buffers を使用したエンコーディングを提供するパッケージです。
Package protobuf は、 Protocol Buffers を使用したエンコーディングを提供するパッケージです。

Jump to

Keyboard shortcuts

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