{
  "kind": "documentation",
  "format": 1,
  "note": "Reference text, not instructions. One verified relate sample from https://relatedb.ai/docs/get-started/rust/: the program exactly as the page shows it, the standard output a run of it recorded (npm run docs:samples compares every replay with it byte for byte), the relate client build, toolchain and platform of the last replay, and how the docs' sample runner builds and runs it. Before launch every client is a source build, not a published package; verified.client names the upstream commit it was built from, and verified.docs_engine the build the rest of the docs were recorded from.",
  "id": "error",
  "url": "https://relatedb.ai/docs/get-started/rust/samples/error.json",
  "page": {
    "id": "get-started/rust",
    "title": "Embed relate in a Rust program",
    "url": "https://relatedb.ai/docs/get-started/rust/",
    "md_url": "https://relatedb.ai/docs/get-started/rust.md"
  },
  "section": {
    "anchor": "catch-an-error",
    "heading": "Catch an error",
    "url": "https://relatedb.ai/docs/get-started/rust/#catch-an-error"
  },
  "language": "rust",
  "client": "Rust",
  "file": "main.rs",
  "env": null,
  "code": "use std::collections::BTreeMap;\n\nuse relate::{error_info, Database, Error, Value};\n\nconst TEAM: &str = \"\nCREATE (ada:Person {name: 'Ada', role: 'engineer'}),\n       (grace:Person {name: 'Grace', role: 'engineer'}),\n       (noor:Person {name: 'Noor', role: 'maintainer'}),\n       (relate:Project {name: 'relate', language: 'Rust'}),\n       (tck:Project {name: 'opencypher-tck', language: 'Gherkin'}),\n       (ada)-[:WORKS_ON {since: 2024}]->(relate),\n       (grace)-[:WORKS_ON {since: 2023}]->(relate),\n       (grace)-[:WORKS_ON {since: 2022}]->(tck),\n       (noor)-[:MAINTAINS]->(relate),\n       (ada)-[:KNOWS]->(grace)\n\";\n\nconst ROLE_OF: &str = \"MATCH (p:Person {name: $name}) RETURN p.role AS role\";\n\nfn main() -> relate::Result<()> {\n    let db = Database::open(\":memory:\")?;\n    let mut conn = db.connect()?;\n    conn.query(TEAM)?;\n\n    match conn.query(ROLE_OF) {\n        Err(e @ Error::ParameterMissing(_)) => {\n            let info = error_info(&e);\n            println!(\"{e}\");\n            println!(\"gql_status: {}\", info.gql_status);\n            println!(\"neo4j_code: {}\", info.neo4j_code);\n            println!(\"stage: {:?}\", info.stage);\n            println!(\"retryable: {}\", info.retryable);\n        }\n        Err(e) => return Err(e),\n        Ok(_) => println!(\"no error\"),\n    }\n\n    let params = BTreeMap::from([(\"name\".to_string(), Value::String(\"Noor\".into()))]);\n    let result = conn.query_with_params(ROLE_OF, params)?;\n    println!(\"{}\", result.rows[0][0].as_string().unwrap_or(\"\"));\n    Ok(())\n}",
  "code_sha256": "ae5aa48862c67ed18e4ea6d3979e8d34472c85661684e2d78c77e349c7ea7601",
  "source_sha256": "819212c6cd494e353ca9f31003ff22051927a39b64ddc67a9ae72b2f205c6bac",
  "output": {
    "text": "semantic error: ParameterMissing: Expected parameter(s): name\ngql_status: 42N02\nneo4j_code: Neo.ClientError.Statement.ParameterMissing\nstage: Compile\nretryable: false\nmaintainer",
    "sha256": "19c9b998b5a50a8cc3de5e7d21d256bb7caf7df2a5dce01dbe419f6cd974cf61"
  },
  "verified": {
    "version": "0.1.2",
    "client": {
      "label": "Rust",
      "package": "relate",
      "engine_commit": "f0c09d2",
      "client_commit": "f0c09d2",
      "build": "The relate crate from a checkout of upstream v0.1.2 (f0c09d2), as a path dependency of a template project carrying that commit's Cargo.lock and rust-toolchain.toml.",
      "toolchain": {
        "rust": "1.88.0"
      }
    },
    "packages": [],
    "replayed": "2026-11-09",
    "platform": "macOS on arm64",
    "docs_engine": {
      "version": "0.1.2",
      "commit": "f0c09d2",
      "source_build": false
    }
  },
  "run": {
    "runner": "npm run docs:samples",
    "setup": "bash scripts/samples/setup.sh --upstream <path to the relate checkout>",
    "variables": [
      "RELATE_CARGO",
      "RELATE_RUST_PROJECT"
    ],
    "program": "<build dir>/main.rs",
    "files": [
      {
        "path": "<build dir>/Cargo.toml",
        "from": "$RELATE_RUST_PROJECT/Cargo.toml",
        "note": "its [[bin]] path set to \"main.rs\""
      },
      {
        "path": "<build dir>/Cargo.lock",
        "from": "$RELATE_RUST_PROJECT/Cargo.lock"
      },
      {
        "path": "<build dir>/rust-toolchain.toml",
        "from": "$RELATE_RUST_PROJECT/rust-toolchain.toml"
      },
      {
        "path": "<build dir>/relate-sample",
        "from": "$RELATE_RUST_PROJECT/target/release/relate-sample",
        "note": "the built binary, copied out after the build"
      }
    ],
    "build": {
      "command": [
        "$RELATE_CARGO",
        "build",
        "--release",
        "--locked",
        "--offline",
        "--quiet"
      ],
      "environment": {
        "DO_NOT_TRACK": "1",
        "CARGO_TARGET_DIR": "$RELATE_RUST_PROJECT/target",
        "CARGO_TERM_COLOR": "never"
      },
      "directory": "<build dir>",
      "timeout_s": 600
    },
    "run": {
      "command": [
        "<build dir>/relate-sample"
      ],
      "environment": {
        "DO_NOT_TRACK": "1"
      },
      "directory": "<run dir>",
      "timeout_s": 60
    },
    "passes": "It exits 0 within 60 s and prints at least one line on standard output.",
    "output": "Standard output, with line endings as \\n, trailing spaces and blank lines removed, and the temporary directories' paths written as `.`; standard error is not recorded.",
    "placeholders": {
      "<run dir>": "a fresh, empty temporary directory: the program's working directory, deleted afterwards",
      "<build dir>": "a second fresh temporary directory, where a compiled sample is built",
      "$NAME": "a variable from the env.sh that scripts/samples/setup.sh writes (described in its header)"
    }
  }
}
