Skip to main content

spell_within

Function spell_within 

Source
pub fn spell_within<'a, S: Spelling<'a>>(
    spelling: &S,
    at: S::At,
    value: &'a Value,
    max_bytes: usize,
) -> Result<Option<String>, DataError>
Expand description

Writes value, known to spelling as at, when its UTF-8 takes at most max_bytes bytes, and returns None otherwise.

Writing stops soon after the text passes max_bytes, so a value whose text would be far longer costs no more than the bound and the one part that crossed it. The walk keeps what is still to write on a stack on the heap, so a value nested deeper than the native stack is written too.

ยงErrors

DataError::NotData on reaching a value that is not data.