2024-08-15 15:12:42 +00:00
|
|
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
|
|
|
|
package data
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2024-09-19 08:03:23 +00:00
|
|
|
"net/url"
|
2024-10-16 17:26:42 +00:00
|
|
|
"decl/internal/transport"
|
2024-08-15 15:12:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrInvalidURI error = errors.New("Invalid URI")
|
|
|
|
)
|
|
|
|
|
2024-10-16 17:26:42 +00:00
|
|
|
type URIParser interface {
|
|
|
|
URL() *url.URL
|
|
|
|
NewResource(document Document) (newResource Resource, err error)
|
|
|
|
ConstructResource(res Resource) (err error)
|
|
|
|
Converter() (converter Converter, err error)
|
|
|
|
Exists() bool
|
|
|
|
|
|
|
|
ContentReaderStream() (*transport.Reader, error)
|
|
|
|
ContentWriterStream() (*transport.Writer, error)
|
|
|
|
|
|
|
|
String() string
|
|
|
|
SetURL(url *url.URL)
|
|
|
|
Extension() (string, string)
|
|
|
|
|
|
|
|
ContentType() string
|
|
|
|
IsEmpty() bool
|
|
|
|
}
|
|
|
|
|
2024-08-15 15:12:42 +00:00
|
|
|
type Identifier interface {
|
|
|
|
URI() string
|
2024-10-16 17:26:42 +00:00
|
|
|
SetParsedURI(URIParser) error
|
2024-09-19 08:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type DocumentElement interface {
|
|
|
|
Identifier
|
2024-08-15 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Selector[Item comparable] func(r Item) bool
|
|
|
|
|
|
|
|
type ResourceSelector Selector[Resource]
|
|
|
|
|
|
|
|
type DeclarationSelector Selector[Declaration]
|
2024-09-19 08:03:23 +00:00
|
|
|
|
|
|
|
type BlockSelector Selector[Block]
|
|
|
|
|
|
|
|
type ElementSelector Selector[DocumentElement]
|