encoder

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package encoder provides implementations for data encoding and continuation token encoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base64Encoder

type Base64Encoder struct{}

Base64Encoder adheres to the Encoder interface, utilizing the encoding/base64 encoding strategy for base64 encoding.

func NewBase64Encoder

func NewBase64Encoder() *Base64Encoder

NewBase64Encoder creates a new instance of the Encoder interface that employs the base64 encoding strategy provided by the encoding/base64 package.

func (*Base64Encoder) Decode

func (e *Base64Encoder) Decode(s string) ([]byte, error)

Decode performs base64 URL decoding on the input string using the encoding/base64 package.

func (*Base64Encoder) Encode

func (e *Base64Encoder) Encode(data []byte) (string, error)

Encode performs base64 URL encoding on the input byte slice using the encoding/base64 package.

type ContinuationTokenSerializer added in v1.8.0

type ContinuationTokenSerializer interface {
	// Serialize serializes the continuation token into a format readable by ReadChanges
	Serialize(ulid string, objType string) (token []byte, err error)

	// Deserialize deserializes the continuation token into a format readable by ReadChanges
	Deserialize(token string) (ulid string, objType string, err error)
}

func NewStringContinuationTokenSerializer added in v1.8.0

func NewStringContinuationTokenSerializer() ContinuationTokenSerializer

NewStringContinuationTokenSerializer returns a new instance of StringContinuationTokenSerializer. Serializes the continuation token into a string, as ulid & type concatenated by a pipe.

type Encoder

type Encoder interface {
	Decode(string) ([]byte, error)
	Encode([]byte) (string, error)
}

Encoder is an interface that defines methods for decoding and encoding data.

type NoopEncoder added in v0.1.5

type NoopEncoder struct{}

NoopEncoder is an implementation of the Encoder interface that performs no actual encoding or decoding.

func (NoopEncoder) Decode added in v0.1.5

func (e NoopEncoder) Decode(s string) ([]byte, error)

Decode returns the input string as a byte slice.

func (NoopEncoder) Encode added in v0.1.5

func (e NoopEncoder) Encode(data []byte) (string, error)

Encode returns the input byte slice as a string.

type StringContinuationTokenSerializer added in v1.8.0

type StringContinuationTokenSerializer struct{}

StringContinuationTokenSerializer is a ContinuationTokenSerializer that serializes the continuation token as a string.

func (*StringContinuationTokenSerializer) Deserialize added in v1.8.0

func (ts *StringContinuationTokenSerializer) Deserialize(continuationToken string) (ulid string, objType string, err error)

Deserialize deserializes the continuation token from a string, as ulid & type concatenated by a pipe.

func (*StringContinuationTokenSerializer) Serialize added in v1.8.0

func (ts *StringContinuationTokenSerializer) Serialize(ulid string, objType string) ([]byte, error)

Serialize serializes the continuation token into a string, as ulid & type concatenated by a pipe.

type TokenEncoder added in v0.1.5

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

TokenEncoder combines an encrypter and an encoder to provide functionality for encoding and decoding tokens.

func NewTokenEncoder added in v0.1.5

func NewTokenEncoder(encrypter encrypter.Encrypter, encoder Encoder) *TokenEncoder

NewTokenEncoder constructs a TokenEncoder with the provided encrypter and encoder.

func (*TokenEncoder) Decode added in v0.1.5

func (e *TokenEncoder) Decode(s string) ([]byte, error)

Decode first decodes the input string using its internal decoder, and subsequently decrypts the resulting data using its encrypter.

func (*TokenEncoder) Encode added in v0.1.5

func (e *TokenEncoder) Encode(data []byte) (string, error)

Encode first encrypts the provided data using its internal encrypter, and then encodes the resulting encrypted data using its encoder.

Jump to

Keyboard shortcuts

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