transform

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package transform implements a blob store that can transform blobs into and out of a nested store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flate

type Flate struct {
	Level int
}

Flate is a Transformer implementing RFC1951 DEFLATE compression.

func (Flate) In

func (f Flate) In(_ context.Context, inp []byte) ([]byte, error)

In implements Transformer.In.

func (Flate) Out

func (f Flate) Out(_ context.Context, inp []byte) ([]byte, error)

Out implements Transformer.Out.

type LZW

type LZW struct {
	Order lzw.Order
}

LZW is a Transformer implementing lzw compression.

func (LZW) In

func (l LZW) In(_ context.Context, inp []byte) ([]byte, error)

In implements Transformer.In.

func (LZW) Out

func (l LZW) Out(_ context.Context, inp []byte) ([]byte, error)

Out implements Transformer.Out.

type Store

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

Store is a blob store wrapped a nested anchor.Store and a Transformer. Blobs are transformed according to the Transformer on their way in and out of the nested store.

func New

func New(ctx context.Context, s anchor.Store, x Transformer, a string) (*Store, error)

New produces a new Store. It uses s as backing storage, containing transformed blobs and the mapping from blob refs to transformed-blob refs. Blobs are transformed into and out of s using the Transformer x. The ref mapping is a schema.Map in s whose root ref is given by the anchor name a.

func (*Store) Get

func (s *Store) Get(ctx context.Context, ref bs.Ref) (bs.Blob, error)

Get implements bs.Getter.Get.

func (*Store) ListRefs

func (s *Store) ListRefs(ctx context.Context, start bs.Ref, f func(bs.Ref) error) error

ListRefs implements bs.Getter.ListRefs.

func (*Store) Put

func (s *Store) Put(ctx context.Context, blob bs.Blob) (bs.Ref, bool, error)

Put implements bs.Store.Put.

type Transformer

type Transformer interface {
	// In transforms a blob on its way into the store.
	In(context.Context, []byte) ([]byte, error)

	// Out transforms a blob on its way out of the store.
	Out(context.Context, []byte) ([]byte, error)
}

Transformer tells how to transform a blob on its way into and out of a Store. Out should be the inverse of In.

Jump to

Keyboard shortcuts

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