StructOp Handbook
Contents Examples Commands
Handbook / Providers and libraries

Providers

StructOp reads your declarations and checks their types. A provider defines the abilities you can use and supplies the templates that turn them into C or Rust. For example, a terminal game uses a provider to draw characters and read keys.

For applications shared between C and Rust, use the portable provider families. The core family is implicit in a project with no provider entries.

On this page

Choose a provider#

Find your provider in the Provider registry and select the version recorded in your project lock file. Official provider pages include an intent.st example and a declaration reference for each version.

Each concrete provider declares its implementation language in its schema. For a portable family, structop init installs and locks both implementations. For a directly named concrete provider, its language must match the target in intent.st. The paired providers share an application vocabulary. Some constructs, including inline C, stored pointers and bindings generated for one language, are target-specific.

A project names its providers in intent.st; version = "@latest" selects, on the first initialization, the newest approved version that this StructOp can run, and structop init locks the exact version. A version that needs a newer StructOp is passed over with a note.

Where init gets providers#

In the registry-enabled CLI, declare the provider in intent.st and run structop init. On a clean installation, the CLI downloads the approved package over HTTPS, verifies its archive checksum and file inventory, and installs it in the project. A verified project copy or installation mirror supports offline use. How providers reach you says which providers need a key and when this download is available.

For private GitLab packages, configure a publisher-issued read-only package credential once in ~/.structop/credentials/gitlab.com.netrc with mode 0600. Use a machine-specific netrc entry for gitlab.com with the assigned login and password. Keep credentials outside the project.

init copies verified files into .structop/providers/ and records the version in .structop/providers.lock. Later commands verify the project copy when loading it. If verification fails, restore the reviewed package and recreate the affected project copy. An existing lock continues to pin its version; use structop init -upgrade to select a newer approved version.

For local binding development, set STRUCTOP_DEV_BINDINGS=1 in the development shell. This permits unregistered C/ and Crate/ providers from ~/.structop/providers, including the files generated by structop bind. Unset it to return to normal verification. A development-mode lock does not grant approval in normal mode.

How providers reach you#

Status. The access model below is what StructOp 0.1.0 does. The signed index and the official provider downloads are published.

An installer never contains a provider. structop init downloads each provider that intent.st names, checks it, installs it into .structop/providers/ and records its exact version and digest in .structop/providers.lock. If any provider is refused, structop init installs none of them and writes no lock, though it may still save a newer provider index. structop init refreshes the provider index each time it runs; validate, plan, apply and the other commands never contact the network.

ProviderWhat you need
Official providers (StructOp/c, rust, curses, bracket-lib, gtk2, gtk3, gtk-rs)No key
Community providers that a StructOp maintainer has approvedNo key
Private providersA read-only credential that their publisher gives you, kept in ~/.structop/credentials/ as described above

Approved providers are listed in a signed index. structop init checks the signature before it trusts a single entry, so a provider approved after you installed StructOp works at your next structop init and needs no new StructOp version. A version that has been withdrawn is refused, and the project’s other providers are not installed either: the command reports that the version has been revoked and asks you to choose another and run structop init -upgrade. Copies already installed stop being usable through StructOp; code generated earlier stays as it is.

Official providers come under the licence terms: free for personal use and for individuals and organisations below the thresholds set there, with a paid licence for larger organisations. You use them through StructOp, and the applications you generate are yours, free of royalties. Downloading or using an official provider means you accept those terms.

C and Rust language support#

Use the same declarations on both targets for variables, assignment, conditions, loops and functions. Memory operations have narrower support.

What you want to doC targetRust target
Read and write buffers, arrays, lists and bytesWithin declared boundsWithin declared bounds
Pass an address to a function and update the caller’s valuePointer parameterPointer parameter
Store an address for later useTyped pointers and native C pointersDevelopment CLI supports typed local borrows and pointers to whole scalar state values outside shared GUI state
Allocate, resize and release heap storageChecked heap blocks (allocate, resize, release), language provider 2.3.0Checked heap blocks (allocate, resize, release), language provider 2.3.0
Run work on threads, share data under a lock or through atomicsWorkers (threads, start, join) with atomic counters and flags or values guarded by a lock, language provider 2.3.0Workers (threads, start, join) with atomic counters and flags or values guarded by a lock, language provider 2.3.0

The sum and difference example shows a function returning one result and writing a second through a pointer parameter. The same application runs on C and Rust. A stored pointer to a scalar state value can be copied, rebound or written through. Rust rejects assigning a function-local address to a pointer held in program state. The spawn ability creates a game entity. For native library calls, portability depends on having a binding for each target.

Choose a compiler mode#

Set standard alongside lang in the exec object of intent.st. You can omit standard to use the default.

TargetDefaultOther tested settings
Cc11c99, c17, c23
Rust20212018, 2024

C23 availability. The c23 setting was verified in a local development build of StructOp. It requires a C compiler that accepts -std=c23. For Rust, the setting selects the application’s edition. C language revisions · Rust Reference

What the tests cover#

On Apple silicon with Apple Clang 21.0.0 and stable Rust 1.100.0, all 226 compiler-mode checks passed. Six shared applications ran in all seven modes (42 checks), covering variables, loops, writes through pointer parameters, arrays of records, byte order and names that are C23 keywords. The other 184 checks ran all 136 C handbook applications in C23 and all 48 Rust applications in edition 2024.

A separate portability run tested each of the 209 applications on both targets. All 209 passed on their declared target, and 195 passed on the alternate target. The other 14 are target-specific: each uses a library binding, inline C or a storage pattern that belongs to one target in this release.

Tested provider versions#

The following versions were tested with StructOp 0.1.0 on Apple silicon and on Linux ARM64. Each ability and data kind declared by these versions appeared in an application that built and produced the expected output. The counts measure declaration coverage.

ProviderVersionTargetAbility and data kinds exercised
StructOp/c2.2.0C46 of 46
StructOp/rust2.2.0Rust46 of 46
StructOp/curses2.0.0C6 of 6
StructOp/bracket-lib2.0.0Rust6 of 6
StructOp/gtk22.0.2C48 of 48
StructOp/gtk32.0.2C48 of 48
StructOp/gtk-rs2.0.1Rust48 of 48

For C applications that call a function returning a String into a fixed buffer, use StructOp/c 2.2.0 or later.

Anatomy of a provider#

providers/StructOp/curses/2.0.0/
provider.st        the schema: language, abilities, attributes, types, includes, packages
prelude.c          runtime code written once after the includes
game.c.tmpl        one template per ability kind
draw.c.tmpl
bar.support.c      support code, written only when a bar ability is used
...

The schema declares each ability's attributes with a type and rules, and validate enforces them before any code is generated:

provider.st (excerpt)
provider "curses" {
    lang     = "C"
    includes = ["ncurses.h"]
    packages = ["ncurses"]

    enum "Key" {
        values = [none, left, right, up, down, space, enter, escape, a, b, c]
    }

    ability "draw" {
        attribute "x" {
            type     = Expression
            of       = Int
            required = true
        }
        attribute "glyph" {
            type     = Expression
            of       = Char
            required = true
        }
        attribute "color" {
            type = Expression
            of   = Color
        }
    }
}

The template is target-language code (here C) with placeholders. {{x}} prints a typed expression, {{#set color}}…{{/set}} keeps a section only when the attribute is given, {{body}} renders an ability list in place:

Illustrative C template
preview_cell({{x}}, {{y}}, {{glyph}});
{{#set color}}preview_tint({{x}}, {{y}}, {{color}});{{/set}}

Attribute types#

TypeThe value isExample
Stringtext with ${...}, printed through a format stringmessage = "Hi ${var.name}"
Expressiona typed expression, optionally of a typecondition = var.x > 3
VarRefa variable to write, optionally of, buffer, listinto = var.line
AbilityListabilities rendered in place (or as a callback with handler = true)body = [ability.print.A]
CaseListswitch casescases = [{ value = 1, run = [...] }]
Keywordone word from valuesdirection = vertical
ParamList, FieldList, Typeparameters and locals, struct fields, a return typeparams = [{ name = "x", type = Int }]
ExpressionList, NameListlists of expressions or namessize = [400, 300]
ComponentList, ComponentValues, BindListentity componentswith = [Point, Player]
AbilityRefListreferences to abilities that are not rendered in place (a class's methods, the interfaces it implements)methods = [ability.function.square_area]
SignatureListmethod signatures: name, optional params and returnsmethods = [{ name = "area", returns = Float }]

Settings refine an attribute; validate refuses any it does not know. Among them: required, default, of (the type a VarRef or Expression must have), plain (text without ${}), handler (an AbilityList run as a callback), whole = true (a VarRef that must name a whole value, not an element or field, like a loop counter), calls = true (the AbilityRef names the function the ability calls; structop graph draws it) and lists = "interface" (an AbilityRefList of interfaces rather than functions).

A provider written by structop bind is generated for you from a library’s header or a crate; you do not write its schema by hand. For abilities with callbacks or values of their own, the contribution guide of the community catalogue says where to ask.

Versions#

Each provider version is its own folder and never changes once projects use it; new behaviour means a new folder. A new major version (2.0.0) may refuse projects written for the one before; the repository keeps only the current versions, and its history keeps the older folders.

Publishing a provider#

Choose a namespace you control and a concrete version. A community registration identifies the publisher, its documentation, licence, distribution location and supported targets. Publishers retain ownership. They can contribute redistributable files or host their implementation and control access themselves. Catalogue review covers registration and provenance. Evaluate provider code and templates before using them to build an application.

Community registrations · Submit a provider

Publish your own provider. Anyone with a GitLab account can submit one. The contribution guide in the community catalogue project covers the whole path: writing, testing, packaging and registering a provider, how a maintainer reviews it, and how approval and withdrawal work. A merged registration is a listing; the version becomes installable when a maintainer approves it in the signed index.

The official providers listed above are maintained by StructOp. Your distributor supplies the applicable terms and package access. Commercial delivery and subscription access are managed by the publisher.