vrl 0.32.0

Vector Remap Language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::prelude::{Value, ValueError, VrlValueConvert};
use std::borrow::Cow;

#[allow(clippy::result_large_err)]
pub(crate) fn convert_to_string(
    value: &Value,
    to_lowercase: bool,
) -> Result<Cow<'_, str>, ValueError> {
    let string = value.try_bytes_utf8_lossy()?;
    Ok(if to_lowercase {
        Cow::Owned(string.to_lowercase())
    } else {
        string
    })
}