Skip to main content

construct_id_bytes

Function construct_id_bytes 

Source
pub fn construct_id_bytes(
    template: &str,
    partition: &str,
    body: &[u8],
) -> Result<String, RewriteError>
Expand description

Expands template against the resolved partition and the raw document body, reading {body.<path>} scalars straight from the bytes, without parsing body into a Value (ADR-014). The byte-level twin of construct_id for the streaming write path.

String leaves are decoded; number and bool leaves use their source text.

§Errors

As construct_id, plus RewriteError::InvalidJson if body up to a referenced leaf is malformed.

§Examples

use osproxy_rewrite::construct_id_bytes;

let id = construct_id_bytes("{partition}:{body.order_id}", "acme", br#"{"order_id":1001}"#)
    .unwrap();
assert_eq!(id, "acme:1001");