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 ¶
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 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.
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.
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 ¶
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.