Skip to main content

to_string

Function to_string 

Source
pub fn to_string(data_blocks: &HashMap<String, DataBlock>) -> Result<String>
Expand description

Convert data blocks to a STAR format string.

Returns the data blocks as a formatted STAR string without writing to disk. Useful for debugging, logging, or string manipulation.

See also: write(), read()

§Arguments

  • data_blocks - HashMap of data blocks to convert

§Returns

A Result containing the STAR format string or an Error

§Example

use emstar::{to_string, SimpleBlock, DataBlock, DataValue};
use std::collections::HashMap;

let mut data = HashMap::new();
let mut simple = SimpleBlock::new();
simple.set("key", DataValue::String("value".into()));
data.insert("general".to_string(), DataBlock::Simple(simple));

let star_string = to_string(&data)?;
println!("{}", star_string);