datum 1.1.0

Terse, human-writable data format.
Documentation
/*
 * datum-rs - Quick to implement S-expression format
 * Written starting in 2024 by contributors (see CREDITS.txt at repository's root)
 * To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
 * A copy of the Unlicense should have been supplied as COPYING.txt in this repository. Alternatively, you can find it at <https://unlicense.org/>.
 */

use crate::{DatumComposePipe, DatumDecoder, DatumPipeTokenizer, DatumUTF8Decoder};

#[cfg(feature = "alloc")]
use alloc::string::String;

#[cfg(feature = "alloc")]
use crate::{DatumParser, DatumPipe, DatumToken, DatumValue};

// -- token outputting --

/// Char to token parsing pipeline (custom storage)
/// _Added in 1.1.0._
pub type DatumCharToTokenPipeline<B> = DatumComposePipe<DatumDecoder, DatumPipeTokenizer<B>>;

/// Byte to token parsing pipeline (custom storage)
/// _Added in 1.1.0._
pub type DatumByteToTokenPipeline<B> =
    DatumComposePipe<DatumUTF8Decoder, DatumCharToTokenPipeline<B>>;

/// Byte to token parsing pipeline.
#[cfg(feature = "alloc")]
pub fn datum_byte_to_token_pipeline() -> impl DatumPipe<Input = u8, Output = DatumToken<String>> {
    DatumByteToTokenPipeline::default()
}

/// Character to token parsing pipeline.
#[cfg(feature = "alloc")]
pub fn datum_char_to_token_pipeline() -> impl DatumPipe<Input = char, Output = DatumToken<String>> {
    DatumCharToTokenPipeline::default()
}

// -- value outputting --

/// Byte to value parsing pipeline.
#[cfg(feature = "alloc")]
pub fn datum_byte_to_value_pipeline() -> impl DatumPipe<Input = u8, Output = DatumValue> {
    let tokenizer = datum_byte_to_token_pipeline();

    DatumComposePipe(tokenizer, DatumParser::default())
}

/// Char to value parsing pipeline.
#[cfg(feature = "alloc")]
pub fn datum_char_to_value_pipeline() -> impl DatumPipe<Input = char, Output = DatumValue> {
    let tokenizer = datum_char_to_token_pipeline();

    DatumComposePipe(tokenizer, DatumParser::default())
}