StructOp Handbook
Contents Examples Commands

Crate rusqlite gui

GTK window program82 lines of .st230 lines of generated Rust
What the program prints
n=7
n=8
On this page

The .st files#

intent.st
structop {
    type_app {
        exec = {
            lang     = "Rust"
            standard = "2021"
        }
    }

    lib_provider {
        Rust_lang = {
            source  = "StructOp/rust"
            version = "@latest"
        }
        Gui = {
            source  = "StructOp/gtk-rs"
            version = "@latest"
        }
        Db = {
            source  = "Crate/rusqlite"
            version = "@latest"
        }
    }
}

Input, plan and generated Rust#

bind/rusqlite.bind.st · hints for structop bind
bind/rusqlite.bind.st · hints for structop bind
# rusqlite: SQLite for Rust. P = Nothing passes no query parameters; the then chain keeps the
# borrowed Statement inside one ability; Row::get is pinned once for text and once for numbers.
bind "rusqlite" {
    crate    = "rusqlite"
    version  = "0.31.0"
    features = ["bundled"]
    items    = ["Connection::open_in_memory", "Connection::execute_batch", "Connection::prepare", "Row::get"]
}

function "Connection::prepare" {
    then = ["Statement::query_map"]
    variant "connection_prepare_query_map" {
        P = Nothing
        T = Int
    }
}

function "Row::get" {
    variant "row_get_text" {
        I = Size
        T = String
    }
    variant "row_get_int" {
        I = Size
        T = Int
    }
}
structop plan
structop plan
  # program.app will be created
  + program.app (.structop/build/app)
      + ability.value.db
      + ability.value.n
      + ability.connection_open_in_memory.Open
      + ability.app.Gui
      + ability.window.Main
      + ability.button.Count
      + ability.connection_prepare_query_map.Rows
      + ability.row_get_int.N
      + ability.print.Count
      + ability.click.Press
      + ability.quit.Closed

Plan: 1 to add, 0 to change, 0 to destroy.
Generated main.rs

To inspect this generated file, select Rust in intent.st, initialize the project and export its source.

Export locally
structop init
structop apply -source -no-run
Try it
structop bind bind/rusqlite.bind.st    # from the repository root
cd crate-rusqlite-gui    # a folder holding the .st files above
structop init
structop plan
structop apply