Documentation ¶
Index ¶
- Constants
- func DecodeBlock(block blocks.Block) (node.Node, error)
- func IsIscnObject(codec uint64) bool
- func RegisterIscnObjectFactory(codec uint64, schemaName string, factories []CodecFactoryFunc)
- func ValidateParent(version *Number, parent *Cid) error
- type Base
- func (b *Base) Cid() cid.Cid
- func (*Base) Copy() node.Node
- func (b *Base) Decode(data map[string]interface{}) error
- func (b *Base) Encode() (map[string]interface{}, error)
- func (b *Base) GetArray(key string) ([]interface{}, error)
- func (b *Base) GetBytes(key string) ([]byte, error)
- func (b *Base) GetCid(key string) (cid.Cid, error)
- func (b *Base) GetCustom() map[string]interface{}
- func (b *Base) GetData() map[string]interface{}
- func (b *Base) GetInt32(key string) (int32, error)
- func (b *Base) GetInt64(key string) (int64, error)
- func (b *Base) GetLink(key string) (cid.Cid, string, error)
- func (b *Base) GetName() string
- func (b *Base) GetObject(key string) (interface{}, error)
- func (b *Base) GetString(key string) (string, error)
- func (b *Base) GetUint32(key string) (uint32, error)
- func (b *Base) GetUint64(key string) (uint64, error)
- func (b *Base) GetVersion() uint64
- func (b *Base) Links() []*node.Link
- func (b *Base) Loggable() map[string]interface{}
- func (b *Base) MarkNested()
- func (b *Base) MarshalJSON() ([]byte, error)
- func (b *Base) RawData() []byte
- func (b *Base) Resolve(path []string) (interface{}, []string, error)
- func (b *Base) ResolveLink(path []string) (*node.Link, []string, error)
- func (b *Base) SetData(data map[string]interface{}) error
- func (b *Base) SetValidator(validator Validator)
- func (*Base) Size() (uint64, error)
- func (*Base) Stat() (*node.NodeStat, error)
- func (b *Base) String() string
- func (*Base) Tree(path string, depth int) []string
- type Cid
- func (d *Cid) Decode(data interface{}, m *map[string]interface{}) error
- func (d *Cid) Encode(m *map[string]interface{}) error
- func (d *Cid) Link() (*node.Link, error)
- func (d *Cid) Prototype() Data
- func (d *Cid) Resolve(path []string) (interface{}, []string, error)
- func (d *Cid) Set(data interface{}) error
- func (d *Cid) ToJSON(om *ordered.OrderedMap) error
- type Codec
- type CodecFactoryFunc
- type Context
- func (d *Context) Decode(data interface{}, m *map[string]interface{}) error
- func (d *Context) Encode(m *map[string]interface{}) error
- func (d *Context) Prototype() Data
- func (d *Context) Resolve(path []string) (interface{}, []string, error)
- func (d *Context) Set(data interface{}) error
- func (d *Context) ToJSON(om *ordered.OrderedMap) error
- type Data
- type DataArray
- func (d *DataArray) Decode(data interface{}, m *map[string]interface{}) error
- func (d *DataArray) Encode(m *map[string]interface{}) error
- func (d *DataArray) Prototype() Data
- func (d *DataArray) Resolve(path []string) (interface{}, []string, error)
- func (d *DataArray) Set(data interface{}) error
- func (d *DataArray) ToJSON(om *ordered.OrderedMap) error
- type DataBase
- type IscnObject
- type Number
- func (d *Number) Decode(data interface{}, m *map[string]interface{}) error
- func (d *Number) Encode(m *map[string]interface{}) error
- func (d *Number) GetInt32() (int32, error)
- func (d *Number) GetInt64() (int64, error)
- func (d *Number) GetType() NumberType
- func (d *Number) GetUint32() (uint32, error)
- func (d *Number) GetUint64() (uint64, error)
- func (d *Number) Prototype() Data
- func (d *Number) Resolve(path []string) (interface{}, []string, error)
- func (d *Number) Set(data interface{}) error
- func (d *Number) ToJSON(om *ordered.OrderedMap) error
- type NumberType
- type Object
- func (d *Object) Decode(data interface{}, m *map[string]interface{}) error
- func (d *Object) Encode(m *map[string]interface{}) error
- func (d *Object) Prototype() Data
- func (d *Object) Resolve(path []string) (interface{}, []string, error)
- func (d *Object) Set(data interface{}) error
- func (d *Object) ToJSON(om *ordered.OrderedMap) error
- type ObjectPrototypeFunc
- type String
- func (d *String) Decode(data interface{}, m *map[string]interface{}) error
- func (d *String) Encode(m *map[string]interface{}) error
- func (d *String) Get() string
- func (d *String) Prototype() Data
- func (d *String) Resolve(path []string) (interface{}, []string, error)
- func (d *String) Set(data interface{}) error
- func (d *String) ToJSON(om *ordered.OrderedMap) error
- type Timestamp
- func (d *Timestamp) Decode(data interface{}, m *map[string]interface{}) error
- func (d *Timestamp) Encode(m *map[string]interface{}) error
- func (d *Timestamp) Prototype() Data
- func (d *Timestamp) Resolve(path []string) (interface{}, []string, error)
- func (d *Timestamp) Set(data interface{}) error
- func (d *Timestamp) ToJSON(om *ordered.OrderedMap) error
- type Validator
Constants ¶
const ( CodecISCN = 0x0264 CodecRights = 0x0265 CodecStakeholders = 0x0266 CodecContent = 0x0267 CodecEntity = 0x0268 // Internal Codec CodecRight = 0x02BD CodecStakeholder = 0x02D1 CodecTimePeriod = 0x033F )
IPLD Codecs for ISCN See the authoritative document: https://github.com/multiformats/multicodec/blob/master/table.csv
const (
// ContextKey is the key of context of ISCN object
ContextKey = "context"
)
const (
// TimestampPattern is the regexp for specific ISO 8601 datetime string
TimestampPattern = `^[0-9]{4}` + `-` +
`(?:1[0-2]|0[1-9])` + `-` +
`(?:3[01]|0[1-9]|[12][0-9])` + `T` +
`(?:2[0-3]|[01][0-9])` + `:` +
`(?:[0-5][0-9])` + `:` +
`(?:[0-5][0-9])` +
`(?:Z|[+-](?:2[0-3]|[01][0-9]):(?:[0-5][0-9]))$`
)
Variables ¶
This section is empty.
Functions ¶
func DecodeBlock ¶
DecodeBlock decodes the raw IPLD data back to data object
func IsIscnObject ¶
IsIscnObject checks the codec whether belongs an ISCN object
func RegisterIscnObjectFactory ¶
func RegisterIscnObjectFactory(codec uint64, schemaName string, factories []CodecFactoryFunc)
RegisterIscnObjectFactory registers an array of ISCN object factory functions
func ValidateParent ¶
ValidateParent between version and parent CID
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base is the basic block of all kind of ISCN objects
func (*Base) GetVersion ¶
GetVersion returns the schema version of the ISCN object
func (*Base) Links ¶
Links is a helper function that returns all links within this object HINT: Use `ipfs refs <cid>`
func (*Base) MarshalJSON ¶
MarshalJSON convert the block to JSON format
func (*Base) Resolve ¶
Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse
func (*Base) ResolveLink ¶
ResolveLink is a helper function that allows easier traversal of links through blocks
func (*Base) SetValidator ¶
SetValidator sets the validator function
type Cid ¶
type Cid struct { *DataBase // contains filtered or unexported fields }
Cid is a data handler for IPFS CID
type Codec ¶
type Codec interface { IscnObject MarkNested() GetData() map[string]interface{} SetData(map[string]interface{}) error Encode() (map[string]interface{}, error) Decode(map[string]interface{}) error }
Codec is the interface for the CODEC of ISCN object
type CodecFactoryFunc ¶
CodecFactoryFunc returns a factory function to create ISCN object
type Context ¶
type Context struct { *Number // contains filtered or unexported fields }
Context is a data handler for the context of ISCN object
func NewContext ¶
NewContext creates a context of ISCN object with schema name
type Data ¶
type Data interface { Prototype() Data IsRequired() bool IsDefined() bool Set(interface{}) error GetKey() string Encode(*map[string]interface{}) error Decode(interface{}, *map[string]interface{}) error ToJSON(*ordered.OrderedMap) error Resolve(path []string) (interface{}, []string, error) }
Data is the interface for the data property handler
type DataArray ¶
type DataArray struct { *DataBase // contains filtered or unexported fields }
DataArray is an array of data handler
func NewDataArray ¶
NewDataArray creates an array of data handler
type DataBase ¶
type DataBase struct {
// contains filtered or unexported fields
}
DataBase is the base struct for handling data property
func NewDataBase ¶
NewDataBase creates a base struct for handling data property
func (*DataBase) IsRequired ¶
IsRequired checks whether the data handler is required
type IscnObject ¶
type IscnObject interface { node.Node GetName() string GetVersion() uint64 GetCustom() map[string]interface{} GetArray(string) ([]interface{}, error) GetObject(string) (interface{}, error) GetBytes(string) ([]byte, error) GetInt32(string) (int32, error) GetUint32(string) (uint32, error) GetInt64(string) (int64, error) GetUint64(string) (uint64, error) GetString(string) (string, error) GetCid(string) (cid.Cid, error) GetLink(string) (cid.Cid, string, error) MarshalJSON() ([]byte, error) }
IscnObject is the interface for the data object of ISCN object
func Decode ¶
func Decode(rawData []byte, c cid.Cid) (IscnObject, error)
Decode decodes the raw IPLD data back to data object
type Number ¶
type Number struct { *DataBase // contains filtered or unexported fields }
Number is a data handler for the number
func NewNumber ¶
func NewNumber(key string, isRequired bool, ty NumberType) *Number
NewNumber creates a number data handler
func (*Number) GetType ¶
func (d *Number) GetType() NumberType
GetType returns the type of the number
type NumberType ¶
type NumberType int
NumberType is a enum type for the type of a number
const ( // Int32T represents int32 Int32T NumberType = iota // Uint32T represents uint32 Uint32T // Int64T represents int64 Int64T // Uint64T represents uint64 Uint64T )
type Object ¶
type Object struct { *DataBase // contains filtered or unexported fields }
Object is a data handler of a nested ISCN object
func NewObject ¶
func NewObject(key string, isRequired bool, prototypeFunc ObjectPrototypeFunc) *Object
NewObject creates a nested ISCN object data handler
type ObjectPrototypeFunc ¶
type ObjectPrototypeFunc func() Codec
ObjectPrototypeFunc returns a factory function to create ISCN object prototype
type String ¶
type String struct { *DataBase // contains filtered or unexported fields }
String is a data handler for the string
func NewStringWithFilter ¶
NewStringWithFilter creates a string data handler with filter
type Timestamp ¶
type Timestamp struct { *DataBase // contains filtered or unexported fields }
Timestamp is a data handler for a ISO 8601 timestamp string
func NewTimestamp ¶
NewTimestamp creates a ISO 8601 timestamp string handler