core

package
v1.7.3-3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 4 Imported by: 17

Documentation

Overview

Package core defines a set of core interfaces: Identifier, Recorder, Identification, and Matcher

Index

Constants

View Source
const (
	Pronom byte = iota // Pronom is the TNA's PRONOM file format registry
	MIMEInfo
	LOC
)

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 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 represention of the global identifier
	Inspect(...string) string                  // 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, ...int) (chan Result, error) // Given a name/MIME string and bytes, identify the file. Exclude excludes identifiers from an identification run.
	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, int) // Called before matcher starts - should we continue onto 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 Result

type Result interface {
	Index() int
	Basis() string
}

Result is a raw hit that matchers pass on to Identifiers

type SignatureSet

type SignatureSet interface{}

SignatureSet is added to a matcher. It can take any form, depending on the matcher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL