structured-output Rust crate
StructuredOutput is a Rust library that provides a struct for handling structured output with both a string and a JSON value.
Installation
To use this library in your Rust project, add the following to your Cargo.toml file:
[]
= "0.1.0"
Usage
You can then create a new StructuredOutput instance using the new method, which takes a string and a JSON value as arguments:
let lines = "Hello world!";
let json = json!;
let output = new;
You can retrieve the string and JSON value separately using the lines and json methods:
assert_eq!;
assert_eq!;
You can also get the JSON value as a JSON string or a pretty-printed JSON string using the to_json_string and to_json_pretty methods:
assert_eq!;
assert_eq!;
The StructuredOutput implementation of the Display trait defaults to the string value. You can print the string value directly with the println! macro:
println!;
License
This library is licensed under the Apache 2.0 License.