Documentation ¶
Index ¶
Constants ¶
const FileSizeUnknown = -1
FileSizeUnknown (returned by File#Size) denotes a file's size is unknown e.g. HEAD request without Content-Length
Variables ¶
var ErrTODO = errors.New("not implemented")
ErrTODO is a special error type for unimplemented placeholder procedures
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account interface { // Returns a unique identifier for this account. // This will often be the username or e-mail. ID() string }
Account represents a persistent record on a provider (useful e.g. to access restricted files)
type Accountant ¶
type Accountant interface { Provider // Retrieve (existing) account with user input obtained from Prompter param. NewAccount(Prompter) (Account, error) // returns a pointer to an internal account struct // which will be serialized / deserialized against // Example: `return &AccountData{}` NewTemplate() Account }
Accountant is a provider that stores user accounts
type Configured ¶
type Configured interface { Provider // Configure this provider. Can be called multiple times but never concurrently Configure(*Config) }
Configured are providers that require some kind of configuration/initialization
type File ¶
type File interface { URL() *url.URL // -1 if resource is offline / not found Size() int64 // Filename Name() string Checksum() ([]byte, string, hash.Hash) Provider() Provider }
File denotes a remote file object
type MultiResolver ¶
type MultiResolver interface { ResolveMany([]Request) ([]Request, error) // contains filtered or unexported methods }
MultiResolver is a provider which can resolve multiple URLs at once
type Prompter ¶
type Prompter interface { Get(f []Field) (map[string]string, error) Error(display string) Success() }
Prompter asks for user input
type Provider ¶
type Provider interface {
Name() string
}
Provider is the base interface, other interfaces will be dynamically infered
type Request ¶
type Request interface { // Returns the URL of this request. URL() *url.URL // Wrap wraps this Request in a singleton slice. It is a helper for SingleResolvers. Wrap() []Request // ResolvesTo generates a resolved child request which must not be resolved any further. // This must lead to a valid and downloadable resource. ResolvesTo(File) Request // Deadend generates a resolved child request representing an unavailable resource. Deadend(*url.URL) Request // Errors generates a resolved child request representing an errored resource. Errs(*url.URL, error) Request // Yields generates an unresolved child request with the given URL. Yields(*url.URL) Request // Bundles generates multiple unresolved child request with the given URL. Bundles([]*url.URL) []Request }
Request is used between the core module and providers. It must not be subclassed in any way and will panic!
The generating methods must only be called once per request.
type Resolvability ¶
type Resolvability int
Resolvability enum. one of:
- Next (means skip this provider)
- Single (means cannot be combined with other URLs)
- other values mean that those with the same value can be combined.
const ( // Next - this provider cannot handle this Request Next Resolvability = iota // Single - this provider can resolve this Request only on its own Single // Multi - this provider can resolve this Request with others that yield this same value Multi )
type Retriever ¶
type Retriever interface { Provider // returns the Request object that will lead to the file Retrieve(File) (*http.Request, error) // Determines whether this provider can fetch the resource // pointed to by the given URL. // // Returns: // - 0, if this provider cannot operate on the URL. // - > 0, if this provider is suitable for handling the URL. // A higher number denotes a higher suitability (i.e., basic provider will always return 1) // Providers should take remaining traffic etc. into account. CanRetrieve(File) uint }
Retriever is a provider which can download specific URLs
type SingleResolver ¶
type SingleResolver interface { ResolveOne(Request) ([]Request, error) // contains filtered or unexported methods }
SingleResolver is a provider which can only resolve URLs one by one