Documentation
¶
Index ¶
Constants ¶
const ( // Palette refers to color tables. Palette = ContentType(0x00) // Text refers to texts. Text = ContentType(0x01) // Bitmap refers to images. Bitmap = ContentType(0x02) // Font refers to font descriptions. Font = ContentType(0x03) // VideoClip refers to movies (video-mails). VideoClip = ContentType(0x04) // Sound refers to audio samples. Sound = ContentType(0x07) // Geometry refers to 3D models. Geometry = ContentType(0x0F) // Media refers to audio logs and cutscenes. Media = ContentType(0x11) // Map refers to archive data. Map = ContentType(0x30) )
Variables ¶
This section is empty.
Functions ¶
func ErrChunkDoesNotExist ¶
func ErrChunkDoesNotExist(id Identifier) error
ErrChunkDoesNotExist returns an error specifying the given ID doesn't have an associated chunk.
Types ¶
type BlockProvider ¶
type BlockProvider interface { // BlockCount returns the number of available blocks in the chunk. // Unfragmented chunks will always have exactly one block. BlockCount() int // Block returns the reader for the identified block. // Each call returns a new reader instance. // Data provided by this reader is always uncompressed. Block(index int) (io.Reader, error) }
BlockProvider are capable of returning block data of a chunk.
type Chunk ¶
type Chunk struct { // Fragmented tells whether the chunk should be serialized with a directory. // Fragmented chunks can have zero, one, or more blocks. // Unfragmented chunks always have exactly one block. Fragmented bool // ContentType describes how the block data shall be interpreted. ContentType ContentType // Compressed tells whether the data shall be serialized in compressed form. Compressed bool // BlockProvider is the keeper of original block data. // This provider will be referred to if no other data was explicitly set. BlockProvider BlockProvider // contains filtered or unexported fields }
Chunk provides meta information as well as access to its contained blocks.
func (Chunk) Block ¶
Block returns the reader for the identified block. Each call returns a new reader instance. Data provided by this reader is always uncompressed.
func (Chunk) BlockCount ¶
BlockCount returns the number of available blocks in the chunk. Unfragmented chunks will always have exactly one block.
type ContentType ¶
type ContentType byte
ContentType identifies how chunk data shall be interpreted.
type Identifier ¶
type Identifier interface { // Value returns the numerical value of the identifier. Value() uint16 }
Identifier represents an integer key of chunks.
type MemoryBlockProvider ¶
type MemoryBlockProvider [][]byte
MemoryBlockProvider is a block provider backed by data in memory.
func (MemoryBlockProvider) Block ¶
func (provider MemoryBlockProvider) Block(index int) (io.Reader, error)
Block returns the reader for the identified block. Each call returns a new reader instance.
func (MemoryBlockProvider) BlockCount ¶
func (provider MemoryBlockProvider) BlockCount() int
BlockCount returns the number of available blocks.
type Provider ¶
type Provider interface { // IDs returns a list of available IDs this provider can provide. IDs() []Identifier // Provide returns a chunk for the given identifier. Chunk(id Identifier) (*Chunk, error) }
Provider provides chunks from some storage.
func NullProvider ¶
func NullProvider() Provider
NullProvider returns a Provider instance that is empty. It contains no IDs and will not provide any chunk.
type ProviderBackedStore ¶
type ProviderBackedStore struct {
// contains filtered or unexported fields
}
ProviderBackedStore is a chunk store that defaults to a provider for returning chunks.
func NewProviderBackedStore ¶
func NewProviderBackedStore(provider Provider) *ProviderBackedStore
NewProviderBackedStore returns a new store based on the specified provider. The created store will have a snapshot of the current provider; Changes in the list of available IDs are not reflected.
func (*ProviderBackedStore) Chunk ¶
func (store *ProviderBackedStore) Chunk(id Identifier) (*Chunk, error)
Chunk returns a chunk for the given identifier.
func (*ProviderBackedStore) Del ¶
func (store *ProviderBackedStore) Del(id Identifier)
Del removes the chunk with given identifier from the store.
func (*ProviderBackedStore) IDs ¶
func (store *ProviderBackedStore) IDs() []Identifier
IDs returns a list of available IDs this store currently contains.
func (*ProviderBackedStore) Put ¶
func (store *ProviderBackedStore) Put(id Identifier, chunk *Chunk)
Put (re-)assigns an identifier with data. If no chunk with given ID exists, then it is created. Existing chunks are overwritten with the provided data.
type Store ¶
type Store interface { Provider // Del removes the chunk with given identifier from the store. // Trying to remove an unknown identifier has no effect. Del(id Identifier) // Put (re-)assigns an identifier with data. If no chunk with given ID exists, // then it is created. Existing chunks are overwritten with the provided data. Put(id Identifier, chunk *Chunk) }
Store represents a dynamically accessible container of chunks.