2024-08-15 15:12:42 +00:00
|
|
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
|
|
|
|
package data
|
|
|
|
|
|
|
|
import (
|
2024-09-19 08:03:23 +00:00
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrUnsupportedConversion = errors.New("Unsupported conversion")
|
2024-08-15 15:12:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Convert a resource to a document and a document to a resource
|
|
|
|
|
|
|
|
type Emitter interface {
|
2024-09-19 08:03:23 +00:00
|
|
|
Emit(document Document, filter ElementSelector) (Resource, error)
|
2024-08-15 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
2024-09-19 08:03:23 +00:00
|
|
|
type Extractor interface {
|
|
|
|
Extract(resource Resource, filter ElementSelector) (Document, error)
|
2024-08-15 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Converter interface {
|
|
|
|
Typer
|
|
|
|
Emitter
|
2024-09-19 08:03:23 +00:00
|
|
|
Extractor
|
|
|
|
Close() error
|
2024-08-15 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ManyExtractor interface {
|
2024-09-19 08:03:23 +00:00
|
|
|
ExtractMany(resource Resource, filter ElementSelector) ([]Document, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ManyEmitter interface {
|
|
|
|
EmitMany(documents []Document, filter ElementSelector) (Resource, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type DirectoryConverter interface {
|
|
|
|
SetRelative(flag bool)
|
2024-08-15 15:12:42 +00:00
|
|
|
}
|