Documentation ¶
Index ¶
- type Key
- func (k Key) Base() Key
- func (k Key) BaseName() string
- func (k Key) Bytes() []byte
- func (k Key) Child(k2 Key) Key
- func (k Key) ChildString(s string) Key
- func (k *Key) Clean()
- func (k Key) Equal(k2 Key) bool
- func (k Key) IsAncestorOf(other Key) bool
- func (k Key) IsDescendantOf(other Key) bool
- func (k Key) IsTopLevel() bool
- func (k Key) Less(k2 Key) bool
- func (k Key) List() []string
- func (k Key) Parent() Key
- func (k Key) String() string
- type Slice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
A Key represents the unitque identity of an object. Key schema likes file name of a file system,
Key("/tx/0af020217fd26e0b6bf40912bca223b1dd806a21") Key("/block/0af020217fd26e0b6bf40912bca223b1dd806a21") Key("/ttl/peer/a9f827938c7de0")
Inspired by https://github.com/ipfs/go-datastore
func NewKeyFromBytes ¶
NewKeyFromBytes constructs a key from byte slice. it will clean the value.
func NewKeyWithPathList ¶
NewKeyWithPathList constructs a key out of a path slice.
func NewKeyWithPaths ¶
NewKeyWithPaths constructs a key out of a path slice.
func (Key) ChildString ¶
ChildString returns the `child` Key of this Key -- string helper.
func (Key) IsAncestorOf ¶
IsAncestorOf returns whether this key is a prefix of `other`
NewKey("/Ancestor").IsAncestorOf("/Ancestor/Child") true
func (Key) IsDescendantOf ¶
IsDescendantOf returns whether this key contains another as a prefix.
NewKey("/Ancestor/Child").IsDescendantOf("/Ancestor") true
func (Key) IsTopLevel ¶
IsTopLevel returns whether this key has only one namespace.
Click to show internal directories.
Click to hide internal directories.