Skip to content

package asset

import "github.com/cloudboss/unobin/pkg/asset"

Constants

const FormatVersion = 1

Functions

func DisplayReference

func DisplayReference(value string) string

Types

type Asset

type Asset struct {
    Name string
    // contains filtered or unexported fields
}

func (*Asset) Entries

func (a *Asset) Entries() []*Entry

func (*Asset) Entry

func (a *Asset) Entry(internalPath string) (*Entry, bool)

type Cache

type Cache struct {
    // contains filtered or unexported fields
}

func NewCache

func NewCache(catalog *Catalog, requestedRoot string) (*Cache, error)

func (*Cache) HideRootInErrors

func (c *Cache) HideRootInErrors()

func (*Cache) Resolve

func (c *Cache) Resolve(token string) (any, error)

func (*Cache) Root

func (c *Cache) Root() (string, error)

type CapturedAsset

type CapturedAsset struct {
    Name    string
    Entries []CapturedEntry
}

type CapturedEntry

type CapturedEntry struct {
    InternalPath  string
    Kind          EntryKind
    Mode          string
    Content       []byte
    ContentSize   int64
    ContentSHA256 string
    EntryIdentity string
}

type CapturedSet

type CapturedSet struct {
    ID     string
    Assets []CapturedAsset
}

func Capture

func Capture(
    source *resolve.Source,
    sourceFile syntax.SourceFileSpec,
    declarations []syntax.AssetDecl,
    outputPath string,
) (*CapturedSet, error)

type Catalog

type Catalog struct {
    // contains filtered or unexported fields
}

func Open

func Open(body []byte) (*Catalog, error)

func (*Catalog) Content

func (c *Catalog) Content(token string) ([]byte, error)

func (*Catalog) Reference

func (c *Catalog) Reference(token string) (*Reference, bool)

func (*Catalog) Set

func (c *Catalog) Set(id string) (*Set, bool)

func (*Catalog) Sets

func (c *Catalog) Sets() []*Set

func (*Catalog) Verify

func (c *Catalog) Verify() error

type Collection

type Collection struct {
    // contains filtered or unexported fields
}

func (*Collection) Add

func (c *Collection) Add(set *CapturedSet) error

func (*Collection) Catalog

func (c *Collection) Catalog() *Catalog

func (*Collection) Encode

func (c *Collection) Encode() ([]byte, error)

type ContentRef

type ContentRef string

type Entry

type Entry struct {
    ManifestEntry
}

type EntryKind

type EntryKind string

type Manifest

type Manifest struct {
    FormatVersion int                `json:"format-version"`
    AssetSets     []ManifestAssetSet `json:"asset-sets"`
}

type ManifestAsset

type ManifestAsset struct {
    Name    string          `json:"name"`
    Entries []ManifestEntry `json:"entries"`
}

type ManifestAssetSet

type ManifestAssetSet struct {
    ID     string          `json:"id"`
    Assets []ManifestAsset `json:"assets"`
}

type ManifestEntry

type ManifestEntry struct {
    InternalPath  string    `json:"internal-path"`
    Kind          EntryKind `json:"kind"`
    Mode          string    `json:"mode"`
    ContentSize   int64     `json:"content-size"`
    ContentSHA256 string    `json:"content-sha256"`
    EntryIdentity string    `json:"entry-identity"`
    BlobPath      string    `json:"blob-path"`
}

type PathRef

type PathRef string

type Reference

type Reference struct {
    Token         string
    Kind          ReferenceKind
    EntryIdentity string
    AssetName     string
    InternalPath  string
    Asset         *Asset
    Entry         *Entry
}

func ParseReference

func ParseReference(token string) (Reference, bool)

type ReferenceKind

type ReferenceKind string

type Set

type Set struct {
    ID string
    // contains filtered or unexported fields
}

func (*Set) Asset

func (s *Set) Asset(name string) (*Asset, bool)

func (*Set) Assets

func (s *Set) Assets() []*Asset

func (*Set) Catalog

func (s *Set) Catalog() *Catalog

func (*Set) Value

func (s *Set) Value(name, internalPath string) (Value, error)

type Value

type Value struct {
    Path          PathRef    `json:"path"`
    Content       ContentRef `json:"content"`
    ContentSHA256 string     `json:"content-sha256"`
    Mode          string     `json:"mode"`
}