Skip to main content

Module borrowed

Module borrowed 

Source
Expand description

Zero-copy YAML values that borrow strings from the input.

BorrowedValue is the zero-copy counterpart of Value. String scalars and mapping keys use Cow<'a, str>, borrowing directly from the input buffer when no escape processing was needed. This eliminates heap allocations for the majority of YAML content.

§Examples

use noyalib::borrowed::{from_str_borrowed, BorrowedValue};

let yaml = "name: noyalib\nversion: 1\n";
let value: BorrowedValue<'_> = from_str_borrowed(yaml).unwrap();
assert_eq!(value.as_mapping().unwrap().get("name").unwrap().as_str(), Some("noyalib"));

Enums§

BorrowedValue
A zero-copy YAML value that borrows strings from the input.
TransformReason
Why a YAML scalar could not be borrowed directly from the input buffer and had to be materialised into an owned String.

Functions§

from_str_borrowed
Parse YAML into a zero-copy BorrowedValue that borrows from the input.
from_str_borrowed_with_config
Parse YAML into a zero-copy BorrowedValue with custom security limits.