Documentation ¶
Overview ¶
Package core defines a set of core interfaces: Identifier, Recorder, Identification, and Matcher
Index ¶
Constants ¶
const ( Pronom byte = iota // Pronom is the TNA's PRONOM file format registry MIMEInfo LOC Wikidata )
Add additional identifier types here
Variables ¶
This section is empty.
Functions ¶
func RegisterIdentifier ¶
func RegisterIdentifier(id byte, l IdentifierLoader)
RegisterIdentifier allows external packages to add new IdentifierLoaders.
Types ¶
type Hint ¶ added in v1.7.9
Hint is a structure provided by a Recorder before a matcher is run, when asked if it is Satisfied(). A hint identifies if that recorder can be excluded or if there is a pivot list.
type Identification ¶
type Identification interface { String() string // short text that is displayed to indicate the format match Known() bool // does this identifier produce a match Warn() string // identification warning message Values() []string // match response. Slice can be any length, but must be same length as Fields() returned by Identifier Archive() config.Archive // does this format match any of the archive formats (zip, gzip, tar, warc, arc) }
Identification is sent by an identifier when a format matches
type Identifier ¶
type Identifier interface { Add(Matcher, MatcherType) (Matcher, error) Recorder() Recorder // return a recorder for matching Name() string Details() string Fields() []string // Fields of an Identification, first element must be "namespace" Save(*persist.LoadSaver) String() string // A string representation of the global identifier Inspect(...string) (string, error) // String representation of format signatures within the identifier GraphP(int) string // a dot graph representation of the identifier's priorities, missing priorities or implicit priorities Recognise(MatcherType, int) (bool, string) // do you recognise this result index? }
Identifier describes the implementation of a signature format. E.g. there is a PRONOM identifier that implements the TNA's PRONOM format.
func LoadIdentifier ¶
func LoadIdentifier(ls *persist.LoadSaver) Identifier
LoadIdentifier applies the appropriate IdentifierLoader to load an identifier.
type IdentifierLoader ¶
type IdentifierLoader func(*persist.LoadSaver) Identifier
IdentifierLoader unmarshals an Identifer from a LoadSaver.
type Matcher ¶
type Matcher interface { Identify(string, *siegreader.Buffer, ...Hint) (chan Result, error) // Given a name/MIME string and bytes, identify the file. Include the collected Hints String() string }
Matcher does the matching (against the name/mime string or the byte stream) and sends results
type MatcherType ¶
type MatcherType int
MatcherType is used by recorders to tell which type of matcher has sent a result
const ( NameMatcher MatcherType = iota MIMEMatcher ContainerMatcher ByteMatcher TextMatcher XMLMatcher RIFFMatcher )
Add additional Matchers here
type Recorder ¶
type Recorder interface { Record(MatcherType, Result) bool // Record results for each matcher; return true if match recorded (siegfried will iterate through the identifiers until an identifier returns true). Satisfied(MatcherType) (bool, Hint) // Called before matcher starts - should we continue onto this matcher? Should we pass any hints (exclude or pivot) to this matcher? Report() []Identification // Return results as slice Active(MatcherType) // Instruct Recorder that can expect results of type MatcherType. }
Recorder is a mutable object generated by an identifier. It records match results and sends identifications.
type SignatureSet ¶
type SignatureSet interface{}
SignatureSet is added to a matcher. It can take any form, depending on the matcher.