signature

package module
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 8 Imported by: 2

README

Scale Signature

Discord

Golang Rust Typescript

This library contains the definitions and tooling required to test and consume Golang, Rust, and Typescript Signatures for Scale Functions.

Usage and Documentation

Usage instructions and documentation for Scale Signatures is available at https://scale.sh/docs.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/loopholelabs/scale-signature. For more contribution information check out the contribution guide.

License

The Scale Signature project is available as open source under the terms of the Apache License, Version 2.0.

Code of Conduct

Everyone interacting in the Scale Signature project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the CNCF Code of Conduct.

Project Managed By:

Documentation

Overview

Package signature implements the Signature type, that must be exported by Signatures

Index

Constants

This section is empty.

Variables

View Source
var (
	// AcceptedVersions is an array of acceptable Versions
	AcceptedVersions = []Version{V1Alpha}
)
View Source
var (
	VersionErr = errors.New("unknown or invalid version")
)

Functions

func CreateGoSignature

func CreateGoSignature(scaleFilePath string, directory string, signaturePath string) error

func CreateRustSignature added in v0.1.3

func CreateRustSignature(scaleFilePath string, directory string, signaturePath string) error

func Encode

func Encode(writer io.Writer, definition *Definition) error

Encode writes the given definition to the given io.Writer

func ParseSignature

func ParseSignature(signature string) (string, string, string)

ParseSignature parses and returns the Organization, Name, and Version of a signature string. If there is no organization, the organization will be an empty string. If there is no tag, the tag will be an empty string.

func Write

func Write(path string, definition *Definition) error

Write opens a file at the given path and writes the given definition to it

Types

type Context

type Context interface {
	GuestContext() GuestContext // GuestContext of the Context
}

Context is the interface that must be implemented by all Contexts that will be used by the Guest. The runtime does not use any of these methods.

type Definition

type Definition struct {
	DefinitionVersion Version           `json:"definition" yaml:"definition"`
	Name              string            `json:"name" yaml:"name"`
	Version           string            `json:"version" yaml:"version"`
	PublishedVersions PublishedVersions `json:"published" yaml:"published"`
}

Definition is the definition of a signature as well as the published versions

func Decode

func Decode(reader io.Reader) (*Definition, error)

Decode reads the data stored in the given io.Reader and returns a *Definition

func Read

func Read(path string) (*Definition, error)

Read opens a file at the given path and returns a *Definition

type GuestContext

type GuestContext interface {
	FromReadBuffer() error                       // FromReadBuffer deserializes the Context from the global buffer
	ToWriteBuffer() (uint32, uint32)             // ToWriteBuffer serializes the Context to a global buffer and returns the offset and length
	ErrorWriteBuffer(err error) (uint32, uint32) // ErrorWriteBuffer serializes an error into a global buffer and returns the offset and length
}

GuestContext is the interface that must be implemented by the Context of a Signature in order for it to be used by the guest.

type NewSignature added in v0.1.5

type NewSignature[T Signature] func() T

NewSignature is a factory function for creating a new Signature

type PublishedVersion

type PublishedVersion struct {
	Name    string `json:"name" yaml:"name"`
	Version string `json:"version" yaml:"version"`
}

PublishedVersion is the published version of the signature specific to a language

type PublishedVersions

type PublishedVersions struct {
	Go PublishedVersion `json:"go" yaml:"go"`
}

PublishedVersions is a list of published versions of the signature specific to a language

type RuntimeContext

type RuntimeContext interface {
	Read(b []byte) error    // Read updates the Context by decoding the given bytes
	Write() []byte          // Write encodes the Context and returns the encoded bytes
	Error(err error) []byte // Error encodes the given error and returns the encoded bytes
}

RuntimeContext is the interface that must be implemented by the Context of a Signature in order for it to be used by the runtime.

type Signature

type Signature interface {
	RuntimeContext() RuntimeContext // RuntimeContext of the Signature
}

Signature is an interface that must be implemented by all Signatures that will be used by the runtime. The guest does not use any of these methods.

type Version

type Version string

Version is the Version of the ScaleFile definition

const (
	// V1Alpha is the V1 Alpha definition of a Scale Signature
	V1Alpha Version = "v1alpha"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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