blockcode

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package blockcode provides functionalities for packaging a directory into a Blockcode. It includes functions for signing, verifying, encoding and decoding a Blockcode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blockcode

type Blockcode struct {
	Manifest *Manifest
	// contains filtered or unexported fields
}

Blockcode defines a block code

func FromBytes

func FromBytes(bs []byte) (*Blockcode, error)

FromBytes creates a Blockcode from serialized Blockcode

func FromDir

func FromDir(projectPath string) (*Blockcode, error)

FromDir creates a Blockcode from the content of a directory

func (*Blockcode) Bytes

func (bc *Blockcode) Bytes() []byte

Bytes return bytes representation of the Blockcode

func (*Blockcode) Deflate

func (bc *Blockcode) Deflate(dest string) error

Deflate decompresses the block code into destination while maintaining the folder structure it had during compression. It will return error if a directory of a file already exists or if unable to create the directory.

func (*Blockcode) GetCode

func (bc *Blockcode) GetCode() []byte

GetCode returns the code in its tar archived form

func (*Blockcode) Hash

func (bc *Blockcode) Hash() util.Hash

Hash returns the SHA256 hash of the blockcode

func (*Blockcode) ID

func (bc *Blockcode) ID() string

ID returns the hex representation of Hash()

func (*Blockcode) Size

func (bc *Blockcode) Size() int

Size returns the bytecode size

type FileInfo

type FileInfo struct {
	Content []byte `json:"content"`
	Path    string `json:"path"`
}

FileInfo represents a file in a directory

type Lang

type Lang string

Lang represents a blockcode language

var (
	// LangGo is a Lang representing `Go` programming language
	LangGo Lang = "go"
	// LangTypescript is a Lang representing `Typescript` programming language
	LangTypescript Lang = "typescript"
	// LangPython is a Lang representing `Python` programming language
	LangPython Lang = "python"
)

type Manifest

type Manifest struct {
	Lang        Lang     `msgpack:"lang" json:"lang"`
	LangVersion string   `msgpack:"langVer" json:"langVer"`
	PublicFuncs []string `msgpack:"publicFuncs" json:"publicFuncs"`
}

Manifest describes the blockcode

func (*Manifest) Bytes

func (m *Manifest) Bytes() []byte

Bytes returns the bytes representation of the manifest

Jump to

Keyboard shortcuts

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