core

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package core defines the Identifier, Identification, Recorder, Matcher and Result interfaces. The packages within core (bytematcher, containermatcher, etc.) provide a toolkit for building identifiers based on different signature formats (such as PRONOM).

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
	YAML() string            // long text that should be displayed to indicate the format match
	JSON() string            // JSON match response
	CSV() []string           // CSV match response. Can be any length slice, 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 // first element must be the identifier name
	Save(*persist.LoadSaver)
	String() string                            // A string represention of the global identifier
	Inspect(...string) string                  // String representation of format signatures within the identifier
	GraphP() string                            // a dot graph representation of the priority map within the identifier (if present)
	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(chan Identification)        // Now send results.
	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.

Directories

Path Synopsis
Package bytematcher builds a matching engine from a set of signatures and performs concurrent matching against an input siegreader.Buffer.
Package bytematcher builds a matching engine from a set of signatures and performs concurrent matching against an input siegreader.Buffer.
frames
Package frames describes the Frame interface.
Package frames describes the Frame interface.
frames/tests
Package tests exports shared frames and signatures for use by the other bytematcher packages
Package tests exports shared frames and signatures for use by the other bytematcher packages
patterns
Package patterns describes the Pattern interface.
Package patterns describes the Pattern interface.
patterns/tests
Package tests exports shared patterns for use by the other bytematcher packages
Package tests exports shared patterns for use by the other bytematcher packages
Package persist marshals and unmarshals siegfried signatures as binary data
Package persist marshals and unmarshals siegfried signatures as binary data
Package priority creates a subordinate-superiors map of identifications.
Package priority creates a subordinate-superiors map of identifications.
Package siegreader implements multiple independent Readers (and ReverseReaders) from a single Buffer.
Package siegreader implements multiple independent Readers (and ReverseReaders) from a single Buffer.

Jump to

Keyboard shortcuts

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