image

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 3 Imported by: 9

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 Snapshot added in v0.8.0

type Snapshot struct {
	// ID is the unique ID of the snapshot.
	ID string `json:"id"`
	// Name is the human-readable name of the snapshot.
	Name string `json:"name"`
	// CreatedAt is the time at which the snapshot was taken.
	// Nil if unknown.
	CreatedAt *time.Time `json:"created_at,omitempty"`
}

Snapshot describes an internal snapshot stored in the image.

type SnapshotReader added in v0.8.0

type SnapshotReader interface {
	// Snapshots returns the internal snapshots stored in the image.
	Snapshots() ([]Snapshot, error)
}

SnapshotReader is optionally implemented by an Image that supports reading internal snapshots.

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