cidutil

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 8 Imported by: 60

README

go-cidutil

standard-readme compliant GoDoc Build Status

go-cidutil implements various utilities and helper functions for working with CIDs

Lead Maintainer

Steven Allen

Contribute

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © Protocol Labs, Inc.

Documentation

Index

Constants

View Source
const FormatRef = `` /* 706-byte string literal not displayed */

FormatRef is a string documenting the format string for the Format function

Variables

This section is empty.

Functions

func Format

func Format(fmtStr string, base mb.Encoding, cid c.Cid) (string, error)

Format formats a cid according to the format specificer as documented in the FormatRef constant

func ScanForCid

func ScanForCid(buf []byte) (i, j int, cid c.Cid, cidStr string)

ScanForCid scans bytes for anything resembling a CID. If one is found `i` will point to the begging of the cid and `j` to to the end and the cid will be returned, otherwise `i` and `j` will point the end of the buffer and the cid will be `Undef`.

func Sort

func Sort(s []cid.Cid)

Sort sorts a slice of CIDs

Types

type FormatStringError

type FormatStringError struct {
	Message   string
	Specifier string
}

FormatStringError is the error return from Format when the format string is ill formed

func (FormatStringError) Error

func (e FormatStringError) Error() string

type InlineBuilder

type InlineBuilder struct {
	cid.Builder     // Parent Builder
	Limit       int // Limit (inclusive)
}

InlineBuilder is a cid.Builder that will use the id multihash when the size of the content is no more than limit

func (InlineBuilder) Sum

func (p InlineBuilder) Sum(data []byte) (cid.Cid, error)

Sum implements the cid.Builder interface

func (InlineBuilder) WithCodec

func (p InlineBuilder) WithCodec(c uint64) cid.Builder

WithCodec implements the cid.Builder interface

type Set

type Set = c.Set

func NewSet

func NewSet() *Set

type Slice

type Slice []cid.Cid

Slice is a convenience type for sorting CIDs

func (Slice) Len

func (s Slice) Len() int

func (Slice) Less

func (s Slice) Less(i, j int) bool

func (Slice) Sort

func (s Slice) Sort()

func (Slice) Swap

func (s Slice) Swap(i, j int)

type StreamingSet

type StreamingSet struct {
	Set *Set
	New chan c.Cid
}

StreamingSet is an extension of Set which allows to implement back-pressure for the Visit function

func NewStreamingSet

func NewStreamingSet() *StreamingSet

NewStreamingSet initializes and returns new Set.

func (*StreamingSet) Visitor

func (s *StreamingSet) Visitor(ctx context.Context) func(c c.Cid) bool

Visitor creates new visitor which adds a Cids to the set and emits them to the set.New channel

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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