Rust
Goal
Write a Rust block that works without any crates. Time: 10 minutes. Needs: rustc with edition 2024 support.
Things to know
- The runner compiles with
rustc --edition 2024 -O, then runs the binary. There’s no Cargo, so crates such asserde_jsonaren’t available. - The standard library has no JSON parser. Use Rust for byte, line, or number processing, and use another language for JSON field transformations.
- Use
format!andprintln!for output. Escape{and}by doubling them. Only interpolate values that can’t contain quotes, backslashes, or newlines, or escape them yourself. - Returning
Errfrommainexits with a non-zero code, so the block fails.
Check your run
With the exact compact sample {"trigger":{"text":"Hello from curl"}} (no trailing newline), the output is {"input_bytes":38}. That’s the UTF-8 byte count of the whole file.
Exercise
Publish lines (number): the number of lines in the input file. Test it with multi-line plain text in Step input.