image

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongType = errors.New("wrong image type")

ErrWrongType is returned from [Opener].

Functions

This section is empty.

Types

type Extent added in v0.5.0

type Extent struct {
	// Offset from start of the image in bytes.
	Start int64 `json:"start"`
	// Length of this extent in bytes.
	Length int64 `json:"length"`
	// Set if this extent is allocated.
	Allocated bool `json:"allocated"`
	// Set if this extent is read as zeros.
	Zero bool `json:"zero"`
	// Set if this extent is compressed.
	Compressed bool `json:"compressed"`
}

Extent describes a byte range in the image with the same allocation, compression, or zero status. Extents are aligned to the underlying file system block size (e.g. 4k), or the image format cluster size (e.g. 64k). One extent can describe one or more file system blocks or image clusters.

type Image

type Image interface {
	io.ReaderAt
	io.Closer
	Extent(start, length int64) (Extent, error)
	Type() Type
	Size() int64 // -1 if unknown
	Readable() error
}

Image implements io.ReaderAt and io.Closer.

type ImageInfo

type ImageInfo struct {
	Type  Type  `json:"type"`
	Size  int64 `json:"size"`
	Image `json:"image"`
}

ImageInfo wraps Image for [json.Marshal].

func NewImageInfo

func NewImageInfo(img Image) *ImageInfo

NewImageInfo returns image info.

type OpenWithType

type OpenWithType func(io.ReaderAt, Type) (Image, error)

OpenWithType opens Image with the specified Type. Opener must return ErrWrongType when the image is not parsable with the specified Type.

type Type

type Type string

Type must be a "Backing file format name string" that appears in QCOW2.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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