mod boxed;
mod btreemap;
#[cfg(feature = "std")]
mod hashmap;
mod option;
mod scalar;
mod vec;
use alloc::collections::{BTreeMap, VecDeque};
use alloc::vec::Vec;
use crate::cowstr::CowStr;
use crate::{DecodeError, ESExpr, ESExprTagSet};
pub trait ESExprEncodedEq {
fn is_encoded_eq(&self, other: &Self) -> bool;
}
pub trait ESExprCodec<'a>: ESExprEncodedEq + Sized + 'a {
const TAGS: ESExprTagSet;
fn encode_esexpr(&'a self) -> ESExpr<'a>;
fn decode_esexpr(expr: ESExpr<'a>) -> Result<Self, DecodeError>;
}
pub trait ESExprOptionalFieldCodec<'a>: ESExprEncodedEq + Sized + 'a {
type Element: ESExprCodec<'a> + 'a;
fn encode_optional_field(&'a self) -> Option<ESExpr<'a>>;
fn decode_optional_field(value: Option<ESExpr<'a>>) -> Result<Self, DecodeError>;
}
pub trait ESExprVarArgCodec<'a>: ESExprEncodedEq + Sized + 'a {
type Element: ESExprCodec<'a> + 'a;
fn encode_vararg_element(&'a self, args: &mut Vec<ESExpr<'a>>);
fn decode_vararg_element(
args: &mut VecDeque<ESExpr<'a>>,
constructor_name: &str,
start_index: &mut usize,
) -> Result<Self, DecodeError>;
}
pub trait ESExprDictCodec<'a>
where
Self: Sized + 'a,
{
type Element: ESExprCodec<'a> + 'a;
fn encode_dict_element(&'a self, kwargs: &mut BTreeMap<CowStr<'a>, ESExpr<'a>>);
fn decode_dict_element(
kwargs: &mut BTreeMap<CowStr<'a>, ESExpr<'a>>,
constructor_name: &str,
) -> Result<Self, DecodeError>;
}