application

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxInputBytes 是单次操作允许读取的默认最大输入字节数 / DefaultMaxInputBytes is the default maximum number of input bytes read by one operation
	DefaultMaxInputBytes int64 = 10 << 30 // 10 Gib
	// DefaultMaxOutputBytes 是单次操作允许生成的默认最大输出字节数 / DefaultMaxOutputBytes is the default maximum number of output bytes produced by one operation
	DefaultMaxOutputBytes int64 = 10 << 30 // 10 Gib
	// DefaultMaxArchiveListingBytes 是列出归档前允许物化的默认最大输入字节数 / DefaultMaxArchiveListingBytes is the default maximum number of input bytes materialized before listing an archive
	DefaultMaxArchiveListingBytes int64 = 10 << 30 // 10 Gib
	// DefaultMaxArchiveEntries 是单个归档列表允许返回的默认最大条目数 / DefaultMaxArchiveEntries is the default maximum number of entries returned by one archive listing
	DefaultMaxArchiveEntries = 100_000
)

Variables

This section is empty.

Functions

func ArtifactAttachmentSuffixes

func ArtifactAttachmentSuffixes() []string

ArtifactAttachmentSuffixes 返回作为单个应用制品管理的伴随文件后缀副本 ArtifactAttachmentSuffixes returns a copy of companion suffixes managed as part of one application artifact

Types

type ArchiveEntry

type ArchiveEntry struct {
	// Name 是归档内部使用正斜杠表示的条目路径或名称 / Name is the entry path or name inside the archive using forward slashes where applicable
	Name string
	// Size 是条目解压后的字节数 / Size is the decompressed size of the entry in bytes
	Size int64
	// Kind 是区分普通文件、虚拟文件和序列化文件的条目类别 / Kind classifies the entry as a regular, virtual, or serialized file
	Kind string
}

ArchiveEntry 描述归档中可列出和提取的单个条目 / ArchiveEntry describes one listable and extractable entry in an archive

type ArchiveListing

type ArchiveListing struct {
	// FormatID 是生成列表的归档格式标识符 / FormatID is the archive format identifier used to produce the listing
	FormatID string
	// Entries 是按名称排序的归档条目 / Entries contains archive entries sorted by name
	Entries []ArchiveEntry
	// contains filtered or unexported fields
}

ArchiveListing 表示经过排序和资源限制检查的单个归档视图 / ArchiveListing represents one sorted archive view that has passed resource-limit checks

type ArchivePager

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

ArchivePager 使用进程本地随机密钥签名不透明归档分页游标 / ArchivePager signs opaque archive page cursors with a process-local random key

func NewArchivePager

func NewArchivePager() (*ArchivePager, error)

NewArchivePager 创建具有随机签名密钥的归档分页器 NewArchivePager creates an archive pager with a random signing key

func (*ArchivePager) Decode

func (p *ArchivePager) Decode(listing ArchiveListing, token string) (int, error)

Decode 验证分页游标并返回其在当前归档列表中的偏移量 Decode validates a page cursor and returns its offset within the current archive listing

func (*ArchivePager) Encode

func (p *ArchivePager) Encode(listing ArchiveListing, offset int) (string, error)

Encode 为当前归档列表中的后续偏移量生成签名分页游标 Encode creates a signed page cursor for a subsequent offset in the current archive listing

type Artifact

type Artifact struct {
	// Name 是建议用于保存主要制品的文件名 / Name is the suggested filename for the primary artifact
	Name string
	// FormatID 是制品对应的稳定格式标识符 / FormatID is the stable format identifier associated with the artifact
	FormatID string
	// Representation 表示制品是原生格式还是编辑 JSON / Representation indicates whether the artifact is native data or editing JSON
	Representation Representation
	// Size 是主要制品的字节数 / Size is the primary artifact size in bytes
	Size int64
	// SHA256 是主要制品内容的 SHA-256 摘要 / SHA256 is the SHA-256 digest of the primary artifact content
	SHA256 string
	// Attachments 保存与主要制品共同生成的可选伴随文件 / Attachments contains optional companion files emitted with the primary artifact
	Attachments *ArtifactAttachmentSet
}

Artifact 描述转换或提取操作产生的主要制品 / Artifact describes the primary artifact produced by conversion or extraction

func (Artifact) AttachmentFiles

func (a Artifact) AttachmentFiles() []ArtifactAttachment

AttachmentFiles 返回制品伴随文件的深拷贝 AttachmentFiles returns a deep copy of the artifact companion files

func (Artifact) TotalSize

func (a Artifact) TotalSize() int64

TotalSize 返回主要文件与全部伴随文件的合计字节数 TotalSize returns the combined size in bytes of the primary file and all companion files

type ArtifactAttachment

type ArtifactAttachment struct {
	// Suffix 是追加到主要制品名称后的受管理后缀 / Suffix is the managed suffix appended to the primary artifact name
	Suffix string
	// Name 是伴随文件的完整建议文件名 / Name is the complete suggested filename for the companion file
	Name string
	// Size 是伴随文件的字节数 / Size is the companion file size in bytes
	Size int64
	// SHA256 是伴随文件内容的 SHA-256 摘要 / SHA256 is the SHA-256 digest of the companion file content
	SHA256 string
	// Data 保存在短生命周期工作区中生成的伴随文件内容 / Data retains companion content produced inside the short-lived workspace
	Data []byte
}

ArtifactAttachment 描述与主要制品共同生成的单个伴随文件 / ArtifactAttachment describes one companion file emitted with the primary artifact

type ArtifactAttachmentSet

type ArtifactAttachmentSet struct {
	// Files 是按受管理后缀顺序排列的伴随文件 / Files contains companion files in managed-suffix order
	Files []ArtifactAttachment
}

ArtifactAttachmentSet 保存主要制品的全部伴随文件 / ArtifactAttachmentSet contains all companion files for a primary artifact

type BundleFile

type BundleFile struct {
	// Suffix 为空时表示主要文件,否则必须是受管理伴随文件后缀 / Suffix identifies the primary file when empty or a managed companion suffix otherwise
	Suffix string
	// Reader 提供待安装文件的内容 / Reader supplies the content of the file to install
	Reader io.Reader
	// ExpectedSize 是提交前可选校验的精确字节数 / ExpectedSize is an optional exact byte size verified before commit
	ExpectedSize *int64
	// ExpectedSHA256 是提交前可选校验的十六进制 SHA-256 摘要 / ExpectedSHA256 is an optional hexadecimal SHA-256 digest verified before commit
	ExpectedSHA256 string
}

BundleFile 描述受限根目录制品中待安装的单个主要文件或伴随文件 / BundleFile describes one primary or companion file to install as part of a rooted artifact

type BundleFileMetadata

type BundleFileMetadata struct {
	// Suffix 标识主要文件或受管理伴随文件 / Suffix identifies the primary file or managed companion file
	Suffix string
	// Size 是已安装文件的精确字节数 / Size is the exact installed file size in bytes
	Size int64
	// SHA256 是已安装文件内容的十六进制 SHA-256 摘要 / SHA256 is the hexadecimal SHA-256 digest of the installed file content
	SHA256 string
}

BundleFileMetadata 描述成功安装的主要文件或伴随文件 / BundleFileMetadata describes a successfully installed primary or companion file

type Capability

type Capability struct {
	// Detect 表示是否支持格式检测 / Detect reports whether format detection is supported
	Detect bool
	// Convert 表示是否支持原生格式与编辑 JSON 互转 / Convert reports whether native and editing JSON conversion is supported
	Convert bool
	// Validate 表示是否支持完整格式校验 / Validate reports whether full format validation is supported
	Validate bool
	// Archive 表示是否支持归档列表和条目提取 / Archive reports whether archive listing and entry extraction are supported
	Archive bool
}

Capability 描述一个格式在应用层支持的操作 / Capability describes the application operations supported by a format

type ConvertRequest

type ConvertRequest struct {
	// Source 是需要转换的输入制品 / Source is the input artifact to convert
	Source Source
	// FormatID 是可选的显式格式标识符,空值触发自动检测 / FormatID is an optional explicit format identifier with an empty value requesting detection
	FormatID string
	// To 是转换目标表示形式 / To is the target representation of the conversion
	To Representation
}

ConvertRequest 描述一次原生格式与编辑 JSON 之间的转换请求 / ConvertRequest describes one conversion request between native data and editing JSON

type Detection

type Detection struct {
	// FormatID 是注册表使用的稳定格式标识符 / FormatID is the stable format identifier used by the registry
	FormatID string
	// Game 是检测到的游戏或工具名称 / Game is the detected game or tool name
	Game string
	// FileType 是检测到的规范文件类型 / FileType is the detected canonical file type
	FileType string
	// Representation 表示文件是原生格式还是编辑 JSON / Representation indicates whether the file is native data or editing JSON
	Representation Representation
	// StorageFormat 描述底层存储编码方式 / StorageFormat describes the underlying storage encoding
	StorageFormat string
	// Signature 是格式携带的文件签名 / Signature is the file signature carried by the format
	Signature string
	// Version 是检测到的精确格式版本 / Version is the exact detected format version
	Version int32
	// Name 是不包含目录的源文件名 / Name is the source filename without directory components
	Name string
	// Size 是源文件的字节数 / Size is the source file size in bytes
	Size int64
}

Detection 描述文件格式检测得到的规范元数据 / Detection describes canonical metadata produced by file format detection

type Engine

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

Engine 协调格式检测、转换、校验和归档操作 / Engine coordinates format detection, conversion, validation, and archive operations

func NewEngine

func NewEngine(options EngineOptions) *Engine

NewEngine 使用提供的选项创建应用引擎并为无效限制填充默认值 NewEngine creates an application engine and fills invalid limits with defaults

func (*Engine) ArchiveListingLimits

func (e *Engine) ArchiveListingLimits() (int64, int)

ArchiveListingLimits 返回归档列表独立使用的输入字节数和条目数限制 ArchiveListingLimits returns the independent input-byte and entry-count limits used for archive listings

func (*Engine) Convert

func (e *Engine) Convert(ctx context.Context, request ConvertRequest, output io.Writer) (Artifact, error)

Convert 将输入源转换为目标表示并将主要制品流式写入输出 Convert transforms a source into the target representation and streams the primary artifact to the output

func (*Engine) ConvertBytes

func (e *Engine) ConvertBytes(ctx context.Context, request ConvertRequest) (Artifact, []byte, error)

ConvertBytes 执行转换并将主要制品内容收集到内存中 ConvertBytes performs a conversion and collects the primary artifact content in memory

func (*Engine) Detect

func (e *Engine) Detect(ctx context.Context, source Source) (Detection, error)

Detect 物化抽象输入源并识别其游戏文件格式 Detect materializes an abstract source and identifies its game file format

func (*Engine) ExtractArchiveEntry

func (e *Engine) ExtractArchiveEntry(ctx context.Context, source Source, formatID, entryName string, output io.Writer) (Artifact, error)

ExtractArchiveEntry 从受支持的归档中提取指定条目并流式写入输出 ExtractArchiveEntry extracts a named entry from a supported archive and streams it to the output

func (*Engine) FormatGuide

func (e *Engine) FormatGuide(formatID string) (GuideDocument, error)

FormatGuide 通过引擎注册表返回指定格式的指南 FormatGuide returns the guide for a format through the engine registry

func (*Engine) FormatSchema

func (e *Engine) FormatSchema(formatID string) (SchemaDocument, error)

FormatSchema 通过引擎注册表返回指定格式的编辑 JSON 模式 FormatSchema returns the editing JSON schema for a format through the engine registry

func (*Engine) Formats

func (e *Engine) Formats() []Format

Formats 返回引擎注册表中的公开格式元数据 Formats returns public format metadata from the engine registry

func (*Engine) GetFormatGuide

func (e *Engine) GetFormatGuide(formatID string) (GuideDocument, error)

GetFormatGuide 返回指定格式的指南并作为 FormatGuide 的兼容别名 GetFormatGuide returns the guide for a format as a compatibility alias of FormatGuide

func (*Engine) GetFormatSchema

func (e *Engine) GetFormatSchema(formatID string) (SchemaDocument, error)

GetFormatSchema 返回指定格式的模式并作为 FormatSchema 的兼容别名 GetFormatSchema returns the schema for a format as a compatibility alias of FormatSchema

func (*Engine) ListArchive

func (e *Engine) ListArchive(ctx context.Context, source Source, formatID string) ([]ArchiveEntry, error)

ListArchive 返回归档中经过排序和资源限制检查的条目副本 ListArchive returns a copy of the sorted and resource-checked entries in an archive

func (*Engine) ListArchiveListing

func (e *Engine) ListArchiveListing(ctx context.Context, source Source, formatID string) (ArchiveListing, error)

ListArchiveListing 返回带有源文件指纹的归档列表以供安全分页 ListArchiveListing returns an archive listing with a source fingerprint for safe pagination

func (*Engine) Validate

func (e *Engine) Validate(ctx context.Context, source Source, formatID string) (Detection, error)

Validate 检测并完整解析输入以确认其符合指定或自动识别的格式 Validate detects and fully parses input to confirm that it conforms to the specified or automatically identified format

type EngineOptions

type EngineOptions struct {
	// Registry 是引擎用于查找格式的注册表,空值使用默认注册表 / Registry is the format registry used by the engine with nil selecting the default registry
	Registry *Registry
	// MaxInputBytes 是单次操作允许读取的最大输入字节数 / MaxInputBytes is the maximum number of input bytes read by one operation
	MaxInputBytes int64
	// MaxOutputBytes 是单次操作允许生成的最大输出字节数 / MaxOutputBytes is the maximum number of output bytes produced by one operation
	MaxOutputBytes int64
	// MaxArchiveListingBytes 是列出归档前允许物化的最大输入字节数 / MaxArchiveListingBytes is the maximum number of input bytes materialized before listing an archive
	MaxArchiveListingBytes int64
	// MaxArchiveEntries 是单个归档列表允许返回的最大条目数 / MaxArchiveEntries is the maximum number of entries returned by one archive listing
	MaxArchiveEntries int
}

EngineOptions 配置应用引擎使用的注册表和资源限制 / EngineOptions configures the registry and resource limits used by an application engine

type ErrorCode

type ErrorCode string

ErrorCode 表示在 Go、gRPC 与 MCP 接口之间保持稳定的应用错误代码 / ErrorCode represents an application error code that remains stable across the Go, gRPC, and MCP surfaces

const (
	// CodeInvalidArgument 表示调用参数无效 / CodeInvalidArgument indicates invalid call arguments
	CodeInvalidArgument ErrorCode = "invalid_argument"
	// CodeNotFound 表示请求的资源不存在 / CodeNotFound indicates that the requested resource does not exist
	CodeNotFound ErrorCode = "not_found"
	// CodeUnsupported 表示请求的操作或格式不受支持 / CodeUnsupported indicates that the requested operation or format is unsupported
	CodeUnsupported ErrorCode = "unsupported"
	// CodeResourceExhausted 表示操作超出资源限制 / CodeResourceExhausted indicates that an operation exceeded a resource limit
	CodeResourceExhausted ErrorCode = "resource_exhausted"
	// CodePermissionDenied 表示调用方没有执行操作所需的权限 / CodePermissionDenied indicates that the caller lacks permission to perform the operation
	CodePermissionDenied ErrorCode = "permission_denied"
	// CodeCanceled 表示操作被取消或超过截止时间 / CodeCanceled indicates that an operation was canceled or exceeded its deadline
	CodeCanceled ErrorCode = "canceled"
	// CodeInternal 表示未分类的内部错误 / CodeInternal indicates an unclassified internal error
	CodeInternal ErrorCode = "internal"
)

func CodeOf

func CodeOf(err error) ErrorCode

CodeOf 返回错误对应的公开应用错误代码 CodeOf returns the public application error code associated with an error

type Format

type Format struct {
	// ID 是由游戏名和文件类型组成的稳定格式标识符 / ID is the stable format identifier composed from the game and file type
	ID string
	// Game 是拥有该格式的游戏或工具名称 / Game is the name of the game or tool that owns the format
	Game string
	// FileType 是服务层使用的规范文件类型名称 / FileType is the canonical file type name used by the service layer
	FileType string
	// NativeSuffixes 是该格式接受的原生文件后缀 / NativeSuffixes contains the native file suffixes accepted for the format
	NativeSuffixes []string
	// DefaultName 是缺少可用输入名称时采用的原生文件名 / DefaultName is the native filename used when no suitable input name is available
	DefaultName string
	// Capability 描述该格式支持的应用操作 / Capability describes the application operations supported by the format
	Capability Capability
	// SchemaVersion 是已发布编辑模式的版本 / SchemaVersion is the version of the published editing schema
	SchemaVersion string
	// SchemaID 是已发布编辑模式的规范标识符 / SchemaID is the canonical identifier of the published editing schema
	SchemaID string
	// SchemaSHA256 是已发布编辑模式的 SHA-256 摘要 / SchemaSHA256 is the SHA-256 digest of the published editing schema
	SchemaSHA256 string
	// GuideVersion 是已发布格式指南的版本 / GuideVersion is the version of the published format guide
	GuideVersion string
	// GuideID 是已发布格式指南的规范标识符 / GuideID is the canonical identifier of the published format guide
	GuideID string
	// GuideSHA256 是已发布格式指南的 SHA-256 摘要 / GuideSHA256 is the SHA-256 digest of the published format guide
	GuideSHA256 string
	// GuideVerification 描述已发布指南对整个文件格式的认证等级 / GuideVerification describes the whole-file verification level of the published guide
	GuideVerification string
	// contains filtered or unexported fields
}

Format 描述一个具有稳定应用层标识符的游戏文件格式 / Format describes a game file format with a stable application-level identifier

type GuideDocument

type GuideDocument struct {
	// FormatID 是指南对应的稳定格式标识符 / FormatID is the stable format identifier associated with the guide
	FormatID string
	// Version 是指南文档版本 / Version is the guide document version
	Version string
	// ID 是指南文档的规范标识符 / ID is the canonical identifier of the guide document
	ID string
	// MediaType 是指南文档的媒体类型 / MediaType is the media type of the guide document
	MediaType string
	// SHA256 是指南 JSON 的 SHA-256 摘要 / SHA256 is the SHA-256 digest of the guide JSON
	SHA256 string
	// SchemaID 是指南引用的编辑模式标识符 / SchemaID is the editing schema identifier referenced by the guide
	SchemaID string
	// FormatVerification 描述整个文件格式的认证等级 / FormatVerification describes the verification level of the whole file format
	FormatVerification string
	// JSON 保存可直接交给调用方的指南 JSON / JSON contains the guide JSON ready for callers to consume
	JSON []byte
}

GuideDocument 表示某个已注册格式的版本化编辑指南文档 / GuideDocument represents a versioned editing guide document for one registered format

type OpError

type OpError struct {
	// Op 是发生错误的操作名称 / Op is the name of the operation that failed
	Op string
	// Code 是供调用方判断的稳定错误代码 / Code is the stable error code exposed to callers
	Code ErrorCode
	// Err 是原始底层错误 / Err is the original underlying error
	Err error
}

OpError 为底层错误附加机器可读代码和操作名称 / OpError attaches a machine-readable code and operation name to an underlying error

func (*OpError) Error

func (e *OpError) Error() string

Error 返回包含操作名称和底层原因的错误文本 Error returns error text containing the operation name and underlying cause

func (*OpError) Unwrap

func (e *OpError) Unwrap() error

Unwrap 返回可供标准错误链检查的底层错误 Unwrap returns the underlying error for standard error-chain inspection

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

ReadSeekCloser 定义应用层输入需要的读取、定位和关闭能力 / ReadSeekCloser defines the read, seek, and close capabilities required for application input

type Registry

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

Registry 保存以稳定标识符索引的受支持格式 / Registry stores supported formats indexed by stable identifiers

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry 返回包含 COM3D2 与 KCES 转换器及受支持归档容器的默认注册表 DefaultRegistry returns the default registry containing COM3D2 and KCES converters and supported archive containers

func NewRegistry

func NewRegistry(formats []Format) (*Registry, error)

NewRegistry 校验格式定义并构建带有已发布模式和指南元数据的注册表 NewRegistry validates format definitions and builds a registry enriched with published schema and guide metadata

func (*Registry) FormatGuide

func (r *Registry) FormatGuide(formatID string) (GuideDocument, error)

FormatGuide 解析格式标识符并返回与其已发布编辑模式匹配的指南 FormatGuide resolves a format identifier and returns the guide matching its published editing schema

func (*Registry) FormatSchema

func (r *Registry) FormatSchema(formatID string) (SchemaDocument, error)

FormatSchema 解析格式标识符并返回已发布的编辑 JSON 模式 FormatSchema resolves a format identifier and returns its published editing JSON schema

func (*Registry) Formats

func (r *Registry) Formats() []Format

Formats 返回按格式标识符排序且隐藏内部转换函数的格式元数据副本 Formats returns format metadata copies sorted by identifier with internal converters hidden

func (*Registry) GetFormatGuide

func (r *Registry) GetFormatGuide(formatID string) (GuideDocument, error)

GetFormatGuide 返回指定格式的指南并作为 FormatGuide 的兼容别名 GetFormatGuide returns the guide for a format as a compatibility alias of FormatGuide

func (*Registry) GetFormatSchema

func (r *Registry) GetFormatSchema(formatID string) (SchemaDocument, error)

GetFormatSchema 返回指定格式的模式并作为 FormatSchema 的兼容别名 GetFormatSchema returns the schema for a format as a compatibility alias of FormatSchema

func (*Registry) Lookup

func (r *Registry) Lookup(id string) (Format, bool)

Lookup 按不区分大小写的格式标识符返回格式元数据副本 Lookup returns a copy of format metadata by a case-insensitive format identifier

type Representation

type Representation string

Representation 表示应用层文件内容的形态 / Representation identifies the application-level form of file content

const (
	// RepresentationNative 表示游戏使用的原生文件格式 / RepresentationNative identifies the native file format consumed by the game
	RepresentationNative Representation = "native"
	// RepresentationEditingJSON 表示用于编辑和交换的 JSON 形式 / RepresentationEditingJSON identifies the JSON form used for editing and interchange
	RepresentationEditingJSON Representation = "editing_json"
)

type RootSet

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

RootSet 将公开根标识符映射到服务端配置的受限目录 / RootSet maps public root identifiers to server-configured confined directories

func NewRootSet

func NewRootSet() *RootSet

NewRootSet 创建空的开放根目录集合 NewRootSet creates an empty open root set

func (*RootSet) Add

func (r *RootSet) Add(id, directory string) error

Add 注册只读受限根目录 Add registers a read-only confined root directory

func (*RootSet) AddWritable

func (r *RootSet) AddWritable(id, directory string) error

AddWritable 注册可读取和写入的受限根目录 AddWritable registers a confined root directory that permits reads and writes

func (*RootSet) Close

func (r *RootSet) Close() error

Close 释放根目录集合保留的目录句柄并阻止后续注册 Close releases directory handles retained by the root set and prevents further registration

func (*RootSet) IDs

func (r *RootSet) IDs() []string

IDs 返回按字典序排列的全部已注册根标识符 IDs returns all registered root identifiers in lexical order

func (*RootSet) Resolve

func (r *RootSet) Resolve(id, relativePath string) (Source, error)

Resolve 在指定受限根目录下解析常规文件及其受管理伴随文件 Resolve resolves a regular file and its managed companions beneath a confined root

func (*RootSet) ValidateWrite

func (r *RootSet) ValidateWrite(id, relativePath string) error

ValidateWrite 在不创建目录或文件的情况下检查根权限、路径限制和现有目标 ValidateWrite checks root permissions, path confinement, and an existing destination without creating directories or files

func (*RootSet) WritableIDs

func (r *RootSet) WritableIDs() []string

WritableIDs 返回按字典序排列的可写根标识符 WritableIDs returns writable root identifiers in lexical order

func (*RootSet) WriteBundle

func (r *RootSet) WriteBundle(ctx context.Context, id, relativePath string, files []BundleFile, maxBytes int64) ([]BundleFileMetadata, error)

WriteBundle 在安装任何文件前暂存并校验完整制品集合且在提交失败时恢复原文件 WriteBundle stages and verifies the complete artifact set before installation and restores original files if commit fails

func (*RootSet) WriteFile

func (r *RootSet) WriteFile(ctx context.Context, id, relativePath string, reader io.Reader, maxBytes int64) (int64, string, error)

WriteFile 在同目录临时路径完整写入常规文件后将其原子安装到配置根目录 WriteFile fully writes a regular file to a same-directory temporary path before atomically installing it beneath a configured root

type SchemaDocument

type SchemaDocument struct {
	// FormatID 是模式对应的稳定格式标识符 / FormatID is the stable format identifier associated with the schema
	FormatID string
	// Representation 是该模式描述的应用层表示形式 / Representation is the application representation described by the schema
	Representation Representation
	// Version 是模式文档版本 / Version is the schema document version
	Version string
	// ID 是模式文档的规范标识符 / ID is the canonical identifier of the schema document
	ID string
	// Dialect 是模式使用的 JSON Schema 方言 / Dialect is the JSON Schema dialect used by the document
	Dialect string
	// MediaType 是模式文档的媒体类型 / MediaType is the media type of the schema document
	MediaType string
	// SHA256 是模式 JSON 的 SHA-256 摘要 / SHA256 is the SHA-256 digest of the schema JSON
	SHA256 string
	// NativeSuffixes 是该格式支持的原生文件后缀 / NativeSuffixes contains the native file suffixes supported by the format
	NativeSuffixes []string
	// JSON 保存可直接用于校验或代码生成的模式 JSON / JSON contains schema JSON ready for validation or code generation
	JSON []byte
}

SchemaDocument 表示某个已注册格式的版本化编辑 JSON 契约 / SchemaDocument represents the versioned editing JSON contract for one registered format

type Source

type Source interface {
	// Name 返回适合物化输入时使用的文件名
	// Name returns the filename to use when materializing the source
	Name() string
	// Size 返回源内容的精确字节数
	// Size returns the exact source content size in bytes
	Size() int64
	// Open 打开受上下文约束的独立可定位读取器
	// Open opens an independent seekable reader governed by a context
	Open(context.Context) (ReadSeekCloser, error)
}

Source 表示不限定底层存储方式的具名可定位制品 / Source represents a named seekable artifact without prescribing its storage

func NewBundleSource

func NewBundleSource(primary Source, attachments []SourceAttachment) (Source, error)

NewBundleSource 将受支持的伴随文件关联到主要源并拒绝重复后缀 NewBundleSource associates supported companion files with a primary source and rejects duplicate suffixes

func NewBytesSource

func NewBytesSource(name string, data []byte) Source

NewBytesSource 创建复制输入内容的不可变内存源 NewBytesSource creates an immutable in-memory source by copying the input content

func NewFileSource

func NewFileSource(path string) (Source, error)

NewFileSource 为常规本地文件及其受管理伴随文件创建输入源 NewFileSource creates an input source for a regular local file and its managed companions

type SourceAttachment

type SourceAttachment struct {
	// Suffix 是追加到主要源文件名后的受管理后缀 / Suffix is the managed suffix appended to the primary source name
	Suffix string
	// Source 提供伴随文件的内容和元数据 / Source provides the companion file content and metadata
	Source Source
}

SourceAttachment 表示通过后缀关联到主要输入的伴随文件 / SourceAttachment represents a companion file associated with a primary source by suffix

Jump to

Keyboard shortcuts

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