Documentation ¶
Overview ¶
Package scrap defines the scrap types and functions on them.
Package scrap defines the scrap types and functions on them.
Package scrap defines the scrap types and functions on them.
Package scrap defines the scrap types and functions on them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidScrapType = errors.New("Invalid scrap type.") ErrInvalidScrapName = errors.New("Invalid scrap name.") ErrInvalidLanguage = errors.New("Invalid language.") ErrInvalidHash = errors.New("Invalid SHA256 hash.") ErrInvalidScrapSize = errors.New("Scrap is too large.") )
var AllLangs = []Lang{CPP, JS}
AllLangs is the list of all supported Langs.
var AllTypes = []Type{SVG, SKSL, Particle}
AllTypes is a slice of supported Types.
var MimeTypes = map[Type]string{ SVG: "image/svg+xml", SKSL: "text/plain", Particle: "application/json", }
MimeTypes for each scrap type when served raw.
Functions ¶
Types ¶
type ChildShader ¶
ChildShader is the scrap id of a single child shader along with the name that the uniform should have to access it.
type ParticlesMetaData ¶
type ParticlesMetaData struct { }
ParticlesMetaData is metadata for Particle scraps.
type SKSLMetaData ¶
type SKSLMetaData struct { // Uniforms are all the inputs to the shader. Uniforms []float32 // ImageURL is the URL of an image to load as an input shader. ImageURL string // Child shaders. A slice because order is important when mapping uniform // names in code to child shaders passed to makeShaderWithChildren. Children []ChildShader }
SKSLMetaData is metadata for SKSL scraps.
type ScrapBody ¶
type ScrapBody struct { Type Type Body string // Type specific metadata: SVGMetaData *SVGMetaData `json:",omitempty"` SKSLMetaData *SKSLMetaData `json:",omitempty"` ParticlesMetaData *ParticlesMetaData `json:",omitempty"` }
ScrapBody is the body of scrap stored in GCS and transported by the API.
type ScrapExchange ¶
type ScrapExchange interface { // Expand the given scrap into a full program in the given language and write // that code to the given io.Writer. Expand(ctx context.Context, t Type, hashOrName string, lang Lang, w io.Writer) error // LoadScrap loads a scrap. The 'name' can be either a hash, or if prefixed with // an "@" it is the name of scrap. LoadScrap(ctx context.Context, t Type, hashOrName string) (ScrapBody, error) // CreateScrap and return the hash by the ScrapID. CreateScrap(ctx context.Context, scrap ScrapBody) (ScrapID, error) // DeleteScrap and also delete the name if hashOrName is a name, which is indicated by // the prefix "@". DeleteScrap(ctx context.Context, t Type, hashOrName string) error // PutName creates or updates a name for a given scrap. PutName(ctx context.Context, t Type, name string, nameBody Name) error // GetName retrieves the hash for the given named scrap. GetName(ctx context.Context, t Type, name string) (Name, error) // DeleteName removes the name for the given named scrap. DeleteName(ctx context.Context, t Type, name string) error // ListNames lists all the known names for a given type of scrap. ListNames(ctx context.Context, t Type) ([]string, error) }
ScrapExchange handles reading and writing scraps.
type ScrapID ¶
type ScrapID struct {
Hash SHA256
}
ScrapID contains the identity of a newly created scrap.