types

package
v0.0.0-...-ada256f Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package types consists of common datatypes used by other components for internal representation, not for exporting or indexing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidResource is returned when a resource is unsupported or invalid.
	ErrInvalidResource = errors.New("resource invalid")

	// ErrUnsupportedType is returned when the type of a resource is currently unsupported.
	ErrUnsupportedType = WrappedError{ErrInvalidResource, "unsupported type"}

	// ErrUnexpectedResponse is returned upon unexpected response code.
	ErrUnexpectedResponse = errors.New("unexpected response")

	// ErrRequest is returned on errors in upstream requests.
	ErrRequest = errors.New("request error")
)

Functions

This section is empty.

Types

type AnnotatedResource

type AnnotatedResource struct {
	*Resource
	Source    SourceType `json:",omitempty"`
	Reference `json:",omitempty"`
	Stat      `json:",omitempty"`
}

AnnotatedResource annotates a referenced Resource with additional information.

func (*AnnotatedResource) String

func (r *AnnotatedResource) String() string

String returns the first reference or the URI.

type Metadata

type Metadata map[string]interface{}

Metadata represents matadata for a Resource.

type Protocol

type Protocol uint8

Protocol is an enum specifying the protocol.

const (
	// InvalidProtocol (default) value signifies an invalid protocol.
	InvalidProtocol Protocol = iota
	// IPFSProtocol (currently only supported protocol)
	IPFSProtocol
)

func (Protocol) String

func (p Protocol) String() string

type Provider

type Provider struct {
	*Resource
	Date        time.Time
	Provider    string
	SpanContext trace.SpanContext // SpanContext allows a Resource' processing to be traceable across the program
}

Provider represents a Resource available from an identified provider at a particular moment.

func MockProvider

func MockProvider() Provider

MockProvider returns a provider to be used for mocking.

func (*Provider) String

func (r *Provider) String() string

String defaults to the URI

type Reference

type Reference struct {
	Parent *Resource
	Name   string
}

Reference to indexed item

func (*Reference) String

func (r *Reference) String() string

String shows the name

type Resource

type Resource struct {
	Protocol        // Protocol, e.g. IPFSProtocol
	ID       string // Resource identifier (e.g. CID) for particular Protocol.
}

Resource represents a resource on the dweb.

func (*Resource) IsValid

func (r *Resource) IsValid() bool

IsValid returns true when resource contains a valid value.

func (*Resource) String

func (r *Resource) String() string

String defaults to the URI

func (*Resource) URI

func (r *Resource) URI() string

URI returns a unique identifier for the resource.

type ResourceType

type ResourceType uint8

ResourceType is an enum of possible resource types.

const (
	// UndefinedType is for resources for which the type is as of yet undefined.
	UndefinedType ResourceType = iota
	// UnsupportedType represents an as-of-yet unsupported type.
	UnsupportedType
	// FileType is a regular file.
	FileType
	// DirectoryType is a directory.
	DirectoryType
	// PartialType represents *unreferenced* partial items.
	PartialType
)

func (ResourceType) String

func (t ResourceType) String() string

type SourceType

type SourceType uint8

SourceType is an enum of possible sources for resources.

const (
	// UnknownSource represents items for which no source is defined.
	UnknownSource SourceType = iota
	// SnifferSource represents items sourced from the sniffer.
	SnifferSource
	// DirectorySource represents items sourced from a directory.
	DirectorySource
	// ManualSource represents items sourced through (trusted) manual input.
	ManualSource
	// UserSource represents items sourced from (untrusted) users.
	UserSource
)

func (SourceType) String

func (t SourceType) String() string

type Stat

type Stat struct {
	Type ResourceType
	Size uint64
}

Stat represents the type and size of a Resource.

type WrappedError

type WrappedError struct {
	Err error
	Msg string
}

WrappedError is a generic error type wrapping underlying errors.

func (WrappedError) Error

func (e WrappedError) Error() string

Error returns the message of the current error.

func (WrappedError) Unwrap

func (e WrappedError) Unwrap() error

Unwrap returns the underlying error.

Jump to

Keyboard shortcuts

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