Function streamdal_wasm_transform::transform::truncate
source · pub fn truncate(req: &Request) -> Result<String, TransformError>
Examples found in repository?
examples/usage.rs (line 109)
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
fn truncate_string() {
let sample_json = r#"{"hello": "world"}"#;
let req = transform::Request {
path: "hello".to_string(),
data: sample_json.into(),
value: "".to_string(), // default
truncate_options: Some(TruncateOptions {
length: 3,
truncate_type: TruncateType::Chars,
}),
};
let updated_json = transform::truncate(&req).unwrap();
println!(
"Input JSON: {} || Result JSON: {}",
sample_json, updated_json,
)
}