data

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0, MIT Imports: 8 Imported by: 22

Documentation

Overview

Package data provides tools for working with the UnixFS data structure that is encoded in the "Data" field of the larger a DagPB encoded IPLD node.

See https://github.com/ipfs/specs/blob/master/UNIXFS.md for more information about this data structure.

This package provides an IPLD Prime compatible node interface for this data structure, as well as methods for serializing and deserializing the data structure to protobuf

Index

Constants

View Source
const (
	Data_Raw       int64 = 0
	Data_Directory int64 = 1
	Data_File      int64 = 2
	Data_Metadata  int64 = 3
	Data_Symlink   int64 = 4
	Data_HAMTShard int64 = 5
)
View Source
const (
	Data_DataTypeWireNum                  protowire.Number = 1
	Data_DataWireNum                      protowire.Number = 2
	Data_FileSizeWireNum                  protowire.Number = 3
	Data_BlockSizesWireNum                protowire.Number = 4
	Data_HashTypeWireNum                  protowire.Number = 5
	Data_FanoutWireNum                    protowire.Number = 6
	Data_ModeWireNum                      protowire.Number = 7
	Data_MtimeWireNum                     protowire.Number = 8
	UnixTime_SecondsWireNum               protowire.Number = 1
	UnixTime_FractionalNanosecondsWireNum protowire.Number = 2
	Metadata_MimeTypeWireNum              protowire.Number = 1
)
View Source
const DirectorPerimissionsDefault = 0o0755
View Source
const Field__BlockSizes = "BlockSizes"
View Source
const Field__Data = "Data"
View Source
const Field__DataType = "DataType"
View Source
const Field__Fanout = "Fanout"
View Source
const Field__FileSize = "FileSize"
View Source
const Field__HashType = "HashType"
View Source
const Field__MimeType = "MimeType"
View Source
const Field__Mode = "Mode"
View Source
const Field__Mtime = "Mtime"
View Source
const Field__Nanoseconds = "FractionalNanoseconds"
View Source
const Field__Seconds = "Seconds"
View Source
const FilePermissionsDefault = 0o0644
View Source
const HAMTShardPerimissionsDefault = 0o0755

Variables

View Source
var DataTypeNames = map[int64]string{
	Data_Raw:       "Raw",
	Data_Directory: "Directory",
	Data_File:      "File",
	Data_Metadata:  "Metadata",
	Data_Symlink:   "Symlink",
	Data_HAMTShard: "HAMTShard",
}
View Source
var DataTypeValues = map[string]int64{
	"Raw":       Data_Raw,
	"Directory": Data_Directory,
	"File":      Data_File,
	"Metadata":  Data_Metadata,
	"Symlink":   Data_Symlink,
	"HAMTShard": Data_HAMTShard,
}
View Source
var Type typeSlab

Type is a struct embeding a NodePrototype/Type for every Node implementation in this package. One of its major uses is to start the construction of a value. You can use it like this:

data.Type.YourTypeName.NewBuilder().BeginMap() //...

and:

data.Type.OtherTypeName.NewBuilder().AssignString("x") // ...

Functions

func AppendEncodeUnixFSData

func AppendEncodeUnixFSData(enc []byte, node UnixFSData) []byte

func AppendEncodeUnixFSMetadata

func AppendEncodeUnixFSMetadata(enc []byte, node UnixFSMetadata) []byte

func AppendEncodeUnixTime

func AppendEncodeUnixTime(enc []byte, node UnixTime) []byte

func DefaultPermissions

func DefaultPermissions(u UnixFSData) int

DefaultPermissions gets the default permissions for a UnixFS object based on its type

func EncodeUnixFSData

func EncodeUnixFSData(node UnixFSData) []byte

EncodeUnixFSData serializes a UnixFSData node to bytes

func EncodeUnixFSMetadata

func EncodeUnixFSMetadata(node UnixFSMetadata) []byte

EncodeUnixFSMetadata serializes a UnixFSMetadata node to bytes

Types

type BlockSizes

type BlockSizes = *_BlockSizes

BlockSizes matches the IPLD Schema type "BlockSizes". It has list kind.

func (BlockSizes) AsBool

func (BlockSizes) AsBool() (bool, error)

func (BlockSizes) AsBytes

func (BlockSizes) AsBytes() ([]byte, error)

func (BlockSizes) AsFloat

func (BlockSizes) AsFloat() (float64, error)

func (BlockSizes) AsInt

func (BlockSizes) AsInt() (int64, error)
func (BlockSizes) AsLink() (ipld.Link, error)

func (BlockSizes) AsString

func (BlockSizes) AsString() (string, error)

func (BlockSizes) IsAbsent

func (BlockSizes) IsAbsent() bool

func (BlockSizes) IsNull

func (BlockSizes) IsNull() bool

func (BlockSizes) Iterator

func (n BlockSizes) Iterator() *BlockSizes__Itr

func (BlockSizes) Kind

func (BlockSizes) Kind() ipld.Kind

func (BlockSizes) Length

func (n BlockSizes) Length() int64

func (BlockSizes) ListIterator

func (n BlockSizes) ListIterator() ipld.ListIterator

func (BlockSizes) LookupByIndex

func (n BlockSizes) LookupByIndex(idx int64) (ipld.Node, error)

func (BlockSizes) LookupByNode

func (n BlockSizes) LookupByNode(k ipld.Node) (ipld.Node, error)

func (BlockSizes) LookupBySegment

func (n BlockSizes) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (BlockSizes) LookupByString

func (BlockSizes) LookupByString(string) (ipld.Node, error)

func (BlockSizes) MapIterator

func (BlockSizes) MapIterator() ipld.MapIterator

func (BlockSizes) Prototype

func (BlockSizes) Prototype() ipld.NodePrototype

func (BlockSizes) Representation

func (n BlockSizes) Representation() ipld.Node

func (BlockSizes) Type

func (BlockSizes) Type() schema.Type

type BlockSizes__Itr

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

func (*BlockSizes__Itr) Done

func (itr *BlockSizes__Itr) Done() bool

func (*BlockSizes__Itr) Next

func (itr *BlockSizes__Itr) Next() (idx int64, v Int)

type Bytes

type Bytes = *_Bytes

Bytes matches the IPLD Schema type "Bytes". It has bytes kind.

func (Bytes) AsBool

func (Bytes) AsBool() (bool, error)

func (Bytes) AsBytes

func (n Bytes) AsBytes() ([]byte, error)

func (Bytes) AsFloat

func (Bytes) AsFloat() (float64, error)

func (Bytes) AsInt

func (Bytes) AsInt() (int64, error)
func (Bytes) AsLink() (ipld.Link, error)

func (Bytes) AsString

func (Bytes) AsString() (string, error)

func (Bytes) Bytes

func (n Bytes) Bytes() []byte

func (Bytes) IsAbsent

func (Bytes) IsAbsent() bool

func (Bytes) IsNull

func (Bytes) IsNull() bool

func (Bytes) Kind

func (Bytes) Kind() ipld.Kind

func (Bytes) Length

func (Bytes) Length() int64

func (Bytes) ListIterator

func (Bytes) ListIterator() ipld.ListIterator

func (Bytes) LookupByIndex

func (Bytes) LookupByIndex(idx int64) (ipld.Node, error)

func (Bytes) LookupByNode

func (Bytes) LookupByNode(ipld.Node) (ipld.Node, error)

func (Bytes) LookupBySegment

func (Bytes) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (Bytes) LookupByString

func (Bytes) LookupByString(string) (ipld.Node, error)

func (Bytes) MapIterator

func (Bytes) MapIterator() ipld.MapIterator

func (Bytes) Prototype

func (Bytes) Prototype() ipld.NodePrototype

func (Bytes) Representation

func (n Bytes) Representation() ipld.Node

func (Bytes) Type

func (Bytes) Type() schema.Type

type ErrInvalidDataType

type ErrInvalidDataType struct {
	DataType int64
}

func (ErrInvalidDataType) Error

func (e ErrInvalidDataType) Error() string

type ErrWrongNodeType

type ErrWrongNodeType struct {
	Expected int64
	Actual   int64
}

func (ErrWrongNodeType) Error

func (e ErrWrongNodeType) Error() string

type ErrWrongWireType

type ErrWrongWireType struct {
	Module   string
	Field    string
	Expected protowire.Type
	Actual   protowire.Type
}

func (ErrWrongWireType) Error

func (e ErrWrongWireType) Error() string

type Int

type Int = *_Int

Int matches the IPLD Schema type "Int". It has int kind.

func (Int) AsBool

func (Int) AsBool() (bool, error)

func (Int) AsBytes

func (Int) AsBytes() ([]byte, error)

func (Int) AsFloat

func (Int) AsFloat() (float64, error)

func (Int) AsInt

func (n Int) AsInt() (int64, error)
func (Int) AsLink() (ipld.Link, error)

func (Int) AsString

func (Int) AsString() (string, error)

func (Int) Int

func (n Int) Int() int64

func (Int) IsAbsent

func (Int) IsAbsent() bool

func (Int) IsNull

func (Int) IsNull() bool

func (Int) Kind

func (Int) Kind() ipld.Kind

func (Int) Length

func (Int) Length() int64

func (Int) ListIterator

func (Int) ListIterator() ipld.ListIterator

func (Int) LookupByIndex

func (Int) LookupByIndex(idx int64) (ipld.Node, error)

func (Int) LookupByNode

func (Int) LookupByNode(ipld.Node) (ipld.Node, error)

func (Int) LookupBySegment

func (Int) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (Int) LookupByString

func (Int) LookupByString(string) (ipld.Node, error)

func (Int) MapIterator

func (Int) MapIterator() ipld.MapIterator

func (Int) Prototype

func (Int) Prototype() ipld.NodePrototype

func (Int) Representation

func (n Int) Representation() ipld.Node

func (Int) Type

func (Int) Type() schema.Type

type MaybeBlockSizes

type MaybeBlockSizes = *_BlockSizes__Maybe

func (MaybeBlockSizes) AsNode

func (m MaybeBlockSizes) AsNode() ipld.Node

func (MaybeBlockSizes) Exists

func (m MaybeBlockSizes) Exists() bool

func (MaybeBlockSizes) IsAbsent

func (m MaybeBlockSizes) IsAbsent() bool

func (MaybeBlockSizes) IsNull

func (m MaybeBlockSizes) IsNull() bool

func (MaybeBlockSizes) Must

func (m MaybeBlockSizes) Must() BlockSizes

type MaybeBytes

type MaybeBytes = *_Bytes__Maybe

func (MaybeBytes) AsNode

func (m MaybeBytes) AsNode() ipld.Node

func (MaybeBytes) Exists

func (m MaybeBytes) Exists() bool

func (MaybeBytes) IsAbsent

func (m MaybeBytes) IsAbsent() bool

func (MaybeBytes) IsNull

func (m MaybeBytes) IsNull() bool

func (MaybeBytes) Must

func (m MaybeBytes) Must() Bytes

type MaybeInt

type MaybeInt = *_Int__Maybe

func (MaybeInt) AsNode

func (m MaybeInt) AsNode() ipld.Node

func (MaybeInt) Exists

func (m MaybeInt) Exists() bool

func (MaybeInt) IsAbsent

func (m MaybeInt) IsAbsent() bool

func (MaybeInt) IsNull

func (m MaybeInt) IsNull() bool

func (MaybeInt) Must

func (m MaybeInt) Must() Int

type MaybeString

type MaybeString = *_String__Maybe

func (MaybeString) AsNode

func (m MaybeString) AsNode() ipld.Node

func (MaybeString) Exists

func (m MaybeString) Exists() bool

func (MaybeString) IsAbsent

func (m MaybeString) IsAbsent() bool

func (MaybeString) IsNull

func (m MaybeString) IsNull() bool

func (MaybeString) Must

func (m MaybeString) Must() String

type MaybeUnixFSData

type MaybeUnixFSData = *_UnixFSData__Maybe

func (MaybeUnixFSData) AsNode

func (m MaybeUnixFSData) AsNode() ipld.Node

func (MaybeUnixFSData) Exists

func (m MaybeUnixFSData) Exists() bool

func (MaybeUnixFSData) IsAbsent

func (m MaybeUnixFSData) IsAbsent() bool

func (MaybeUnixFSData) IsNull

func (m MaybeUnixFSData) IsNull() bool

func (MaybeUnixFSData) Must

func (m MaybeUnixFSData) Must() UnixFSData

type MaybeUnixFSMetadata

type MaybeUnixFSMetadata = *_UnixFSMetadata__Maybe

func (MaybeUnixFSMetadata) AsNode

func (m MaybeUnixFSMetadata) AsNode() ipld.Node

func (MaybeUnixFSMetadata) Exists

func (m MaybeUnixFSMetadata) Exists() bool

func (MaybeUnixFSMetadata) IsAbsent

func (m MaybeUnixFSMetadata) IsAbsent() bool

func (MaybeUnixFSMetadata) IsNull

func (m MaybeUnixFSMetadata) IsNull() bool

func (MaybeUnixFSMetadata) Must

type MaybeUnixTime

type MaybeUnixTime = *_UnixTime__Maybe

func (MaybeUnixTime) AsNode

func (m MaybeUnixTime) AsNode() ipld.Node

func (MaybeUnixTime) Exists

func (m MaybeUnixTime) Exists() bool

func (MaybeUnixTime) IsAbsent

func (m MaybeUnixTime) IsAbsent() bool

func (MaybeUnixTime) IsNull

func (m MaybeUnixTime) IsNull() bool

func (MaybeUnixTime) Must

func (m MaybeUnixTime) Must() UnixTime

type String

type String = *_String

String matches the IPLD Schema type "String". It has string kind.

func (String) AsBool

func (String) AsBool() (bool, error)

func (String) AsBytes

func (String) AsBytes() ([]byte, error)

func (String) AsFloat

func (String) AsFloat() (float64, error)

func (String) AsInt

func (String) AsInt() (int64, error)
func (String) AsLink() (ipld.Link, error)

func (String) AsString

func (n String) AsString() (string, error)

func (String) IsAbsent

func (String) IsAbsent() bool

func (String) IsNull

func (String) IsNull() bool

func (String) Kind

func (String) Kind() ipld.Kind

func (String) Length

func (String) Length() int64

func (String) ListIterator

func (String) ListIterator() ipld.ListIterator

func (String) LookupByIndex

func (String) LookupByIndex(idx int64) (ipld.Node, error)

func (String) LookupByNode

func (String) LookupByNode(ipld.Node) (ipld.Node, error)

func (String) LookupBySegment

func (String) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (String) LookupByString

func (String) LookupByString(string) (ipld.Node, error)

func (String) MapIterator

func (String) MapIterator() ipld.MapIterator

func (String) Prototype

func (String) Prototype() ipld.NodePrototype

func (String) Representation

func (n String) Representation() ipld.Node

func (String) String

func (n String) String() string

func (String) Type

func (String) Type() schema.Type

type UnixFSData

type UnixFSData = *_UnixFSData

UnixFSData matches the IPLD Schema type "UnixFSData". It has Struct type-kind, and may be interrogated like map kind.

func DecodeUnixFSData

func DecodeUnixFSData(src []byte) (UnixFSData, error)

func (UnixFSData) AsBool

func (UnixFSData) AsBool() (bool, error)

func (UnixFSData) AsBytes

func (UnixFSData) AsBytes() ([]byte, error)

func (UnixFSData) AsFloat

func (UnixFSData) AsFloat() (float64, error)

func (UnixFSData) AsInt

func (UnixFSData) AsInt() (int64, error)
func (UnixFSData) AsLink() (ipld.Link, error)

func (UnixFSData) AsString

func (UnixFSData) AsString() (string, error)

func (UnixFSData) IsAbsent

func (UnixFSData) IsAbsent() bool

func (UnixFSData) IsNull

func (UnixFSData) IsNull() bool

func (UnixFSData) Kind

func (UnixFSData) Kind() ipld.Kind

func (UnixFSData) Length

func (UnixFSData) Length() int64

func (UnixFSData) ListIterator

func (UnixFSData) ListIterator() ipld.ListIterator

func (UnixFSData) LookupByIndex

func (UnixFSData) LookupByIndex(idx int64) (ipld.Node, error)

func (UnixFSData) LookupByNode

func (n UnixFSData) LookupByNode(key ipld.Node) (ipld.Node, error)

func (UnixFSData) LookupBySegment

func (n UnixFSData) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (UnixFSData) LookupByString

func (n UnixFSData) LookupByString(key string) (ipld.Node, error)

func (UnixFSData) MapIterator

func (n UnixFSData) MapIterator() ipld.MapIterator

func (UnixFSData) Permissions

func (u UnixFSData) Permissions() int

func (UnixFSData) Prototype

func (UnixFSData) Prototype() ipld.NodePrototype

func (UnixFSData) Representation

func (n UnixFSData) Representation() ipld.Node

func (UnixFSData) Type

func (UnixFSData) Type() schema.Type

type UnixFSMetadata

type UnixFSMetadata = *_UnixFSMetadata

UnixFSMetadata matches the IPLD Schema type "UnixFSMetadata". It has Struct type-kind, and may be interrogated like map kind.

func DecodeUnixFSMetadata

func DecodeUnixFSMetadata(src []byte) (UnixFSMetadata, error)

func (UnixFSMetadata) AsBool

func (UnixFSMetadata) AsBool() (bool, error)

func (UnixFSMetadata) AsBytes

func (UnixFSMetadata) AsBytes() ([]byte, error)

func (UnixFSMetadata) AsFloat

func (UnixFSMetadata) AsFloat() (float64, error)

func (UnixFSMetadata) AsInt

func (UnixFSMetadata) AsInt() (int64, error)
func (UnixFSMetadata) AsLink() (ipld.Link, error)

func (UnixFSMetadata) AsString

func (UnixFSMetadata) AsString() (string, error)

func (UnixFSMetadata) IsAbsent

func (UnixFSMetadata) IsAbsent() bool

func (UnixFSMetadata) IsNull

func (UnixFSMetadata) IsNull() bool

func (UnixFSMetadata) Kind

func (UnixFSMetadata) Kind() ipld.Kind

func (UnixFSMetadata) Length

func (UnixFSMetadata) Length() int64

func (UnixFSMetadata) ListIterator

func (UnixFSMetadata) ListIterator() ipld.ListIterator

func (UnixFSMetadata) LookupByIndex

func (UnixFSMetadata) LookupByIndex(idx int64) (ipld.Node, error)

func (UnixFSMetadata) LookupByNode

func (n UnixFSMetadata) LookupByNode(key ipld.Node) (ipld.Node, error)

func (UnixFSMetadata) LookupBySegment

func (n UnixFSMetadata) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (UnixFSMetadata) LookupByString

func (n UnixFSMetadata) LookupByString(key string) (ipld.Node, error)

func (UnixFSMetadata) MapIterator

func (n UnixFSMetadata) MapIterator() ipld.MapIterator

func (UnixFSMetadata) Prototype

func (UnixFSMetadata) Prototype() ipld.NodePrototype

func (UnixFSMetadata) Representation

func (n UnixFSMetadata) Representation() ipld.Node

func (UnixFSMetadata) Type

func (UnixFSMetadata) Type() schema.Type

type UnixTime

type UnixTime = *_UnixTime

UnixTime matches the IPLD Schema type "UnixTime". It has Struct type-kind, and may be interrogated like map kind.

func DecodeUnixTime

func DecodeUnixTime(src []byte) (UnixTime, error)

func (UnixTime) AsBool

func (UnixTime) AsBool() (bool, error)

func (UnixTime) AsBytes

func (UnixTime) AsBytes() ([]byte, error)

func (UnixTime) AsFloat

func (UnixTime) AsFloat() (float64, error)

func (UnixTime) AsInt

func (UnixTime) AsInt() (int64, error)
func (UnixTime) AsLink() (ipld.Link, error)

func (UnixTime) AsString

func (UnixTime) AsString() (string, error)

func (UnixTime) IsAbsent

func (UnixTime) IsAbsent() bool

func (UnixTime) IsNull

func (UnixTime) IsNull() bool

func (UnixTime) Kind

func (UnixTime) Kind() ipld.Kind

func (UnixTime) Length

func (UnixTime) Length() int64

func (UnixTime) ListIterator

func (UnixTime) ListIterator() ipld.ListIterator

func (UnixTime) LookupByIndex

func (UnixTime) LookupByIndex(idx int64) (ipld.Node, error)

func (UnixTime) LookupByNode

func (n UnixTime) LookupByNode(key ipld.Node) (ipld.Node, error)

func (UnixTime) LookupBySegment

func (n UnixTime) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (UnixTime) LookupByString

func (n UnixTime) LookupByString(key string) (ipld.Node, error)

func (UnixTime) MapIterator

func (n UnixTime) MapIterator() ipld.MapIterator

func (UnixTime) Prototype

func (UnixTime) Prototype() ipld.NodePrototype

func (UnixTime) Representation

func (n UnixTime) Representation() ipld.Node

func (UnixTime) Type

func (UnixTime) Type() schema.Type

Directories

Path Synopsis
quick
Package quickbuilder is designed as a replacement for the existing ipfs-files constructor for a simple way to generate synthetic directory trees.
Package quickbuilder is designed as a replacement for the existing ipfs-files constructor for a simple way to generate synthetic directory trees.

Jump to

Keyboard shortcuts

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