Better Parse/Unparse traits

This commit is contained in:
Tony Garnock-Jones 2021-09-17 11:06:53 +02:00
parent df4059ee7a
commit 15a27b4865
4 changed files with 124 additions and 186 deletions

View File

@ -43,7 +43,7 @@ pub fn gen_definition_parser(m: &mut ModuleContext, n: &str, d: &Definition) {
let dest = pattern_parser(&mut ctxt, pat, "value", None, &mut body);
let dest = dest.as_ref().map(String::as_str);
construct(&ctxt, ctorname, false, &pattern_type(pat), dest, &mut body);
item(seq!["fn ", fname.clone(), ctxt.m.generic_static_decls(),
item(seq!["fn ", fname.clone(), ctxt.m.generic_decls(),
"(_ctxt: &", ctxt.m.language_type(), ", value: &", ctxt.m.any_type(), ") -> ",
"std::result::Result<",
names::render_constructor(n), ty.generic_arg(ctxt.m),
@ -69,15 +69,12 @@ pub fn gen_definition_parser(m: &mut ModuleContext, n: &str, d: &Definition) {
}
}
item(seq!["impl", ctxt.m.generic_static_decls(),
" _support::Parse", anglebrackets![ctxt.m.any_type()], " for ",
item(seq!["impl<'a, _L: Into<&'a ", ctxt.m.language_type(), ">, ", ctxt.m.any_type(), ": preserves::value::NestedValue + 'a>",
" _support::Parse", anglebrackets!["_L", ctxt.m.any_type()], " for ",
names::render_constructor(n), ty.generic_arg(ctxt.m), " ",
codeblock![
seq!["type Language = ", ctxt.m.language_type(), ";"],
seq!["fn parse<'a, _LL: Into<&'a Self::Language>>",
"(_ctxt: _LL, value: &", ctxt.m.any_type(), ") ",
" -> std::result::Result<Self, _support::ParseError>",
" where ", ctxt.m.language_type(), ": 'a ",
seq!["fn parse(_ctxt: _L, value: &", ctxt.m.any_type(), ")",
" -> std::result::Result<Self, _support::ParseError> ",
codeblock(body)]]])
});
}

View File

@ -97,14 +97,11 @@ pub fn gen_definition_unparser(m: &mut ModuleContext, n: &str, d: &Definition) {
}
}
item(seq!["impl", ctxt.m.generic_static_decls(),
" _support::Unparse", anglebrackets![ctxt.m.any_type()], " for ",
item(seq!["impl<'a, _L: Into<&'a ", ctxt.m.language_type(), ">, ", ctxt.m.any_type(), ": preserves::value::NestedValue + 'a>",
" _support::Unparse", anglebrackets!["_L", ctxt.m.any_type()], " for ",
names::render_constructor(n), ty.generic_arg(ctxt.m), " ",
codeblock![
seq!["type Language = ", ctxt.m.language_type(), ";"],
seq!["fn unparse<'a, _LL: Into<&'a Self::Language>>",
"(&self, _ctxt: _LL) -> ", ctxt.m.any_type(),
" where ", ctxt.m.language_type(), ": 'a ",
seq!["fn unparse(&self, _ctxt: _L) -> ", ctxt.m.any_type(), " ",
codeblock(body)]]])
});
}

View File

@ -121,51 +121,50 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_atom_kind_boolean<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_boolean<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_0_BOOLEAN { return Err(_support::ParseError::conformance_error("schema.AtomKind::Boolean")); }
let _tmp0 = ();
Ok(AtomKind::Boolean)
}
fn parse_atom_kind_float<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_float<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_1_FLOAT { return Err(_support::ParseError::conformance_error("schema.AtomKind::Float")); }
let _tmp0 = ();
Ok(AtomKind::Float)
}
fn parse_atom_kind_double<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_double<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_2_DOUBLE { return Err(_support::ParseError::conformance_error("schema.AtomKind::Double")); }
let _tmp0 = ();
Ok(AtomKind::Double)
}
fn parse_atom_kind_signed_integer<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_signed_integer<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_3_SIGNED_INTEGER { return Err(_support::ParseError::conformance_error("schema.AtomKind::SignedInteger")); }
let _tmp0 = ();
Ok(AtomKind::SignedInteger)
}
fn parse_atom_kind_string<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_string<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_4_STRING { return Err(_support::ParseError::conformance_error("schema.AtomKind::String")); }
let _tmp0 = ();
Ok(AtomKind::String)
}
fn parse_atom_kind_byte_string<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_byte_string<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_5_BYTE_STRING { return Err(_support::ParseError::conformance_error("schema.AtomKind::ByteString")); }
let _tmp0 = ();
Ok(AtomKind::ByteString)
}
fn parse_atom_kind_symbol<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_symbol<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_6_SYMBOL { return Err(_support::ParseError::conformance_error("schema.AtomKind::Symbol")); }
let _tmp0 = ();
Ok(AtomKind::Symbol)
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for AtomKind {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for AtomKind {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_atom_kind_boolean(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_atom_kind_float(_ctxt, value) { return Ok(r); }
@ -178,9 +177,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for AtomKind {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for AtomKind {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
match self {
AtomKind::Boolean => (&_ctxt.LIT_0_BOOLEAN).clone(),
@ -227,9 +225,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Binding<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Binding<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_7_NAMED { return Err(_support::ParseError::conformance_error("schema.Binding")); }
@ -241,9 +238,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Binding<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Binding<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let Binding {name: _tmp0, pattern: _tmp1} = self;
{
@ -284,9 +280,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Bundle<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Bundle<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_8_BUNDLE { return Err(_support::ParseError::conformance_error("schema.Bundle")); }
@ -297,9 +292,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Bundle<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Bundle<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let Bundle {modules: _tmp0} = self;
{
@ -445,7 +439,7 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_compound_pattern_rec<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
fn parse_compound_pattern_rec<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_9_REC { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::rec")); }
let _tmp1 = ();
@ -455,7 +449,7 @@ fn parse_compound_pattern_rec<_Value: preserves::value::NestedValue + 'static>(_
Ok(CompoundPattern::Rec {label: std::boxed::Box::new(_tmp2), fields: std::boxed::Box::new(_tmp3)})
}
fn parse_compound_pattern_tuple<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
fn parse_compound_pattern_tuple<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_10_TUPLE { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuple")); }
let _tmp1 = ();
@ -469,7 +463,7 @@ fn parse_compound_pattern_tuple<_Value: preserves::value::NestedValue + 'static>
Ok(CompoundPattern::Tuple {patterns: _tmp2})
}
fn parse_compound_pattern_tuple_prefix<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
fn parse_compound_pattern_tuple_prefix<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_11_TUPLE_PREFIX { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuplePrefix")); }
let _tmp1 = ();
@ -484,7 +478,7 @@ fn parse_compound_pattern_tuple_prefix<_Value: preserves::value::NestedValue + '
Ok(CompoundPattern::TuplePrefix {fixed: _tmp2, variable: std::boxed::Box::new(_tmp6)})
}
fn parse_compound_pattern_dict<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
fn parse_compound_pattern_dict<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_12_DICT { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::dict")); }
let _tmp1 = ();
@ -493,9 +487,8 @@ fn parse_compound_pattern_dict<_Value: preserves::value::NestedValue + 'static>(
Ok(CompoundPattern::Dict {entries: std::boxed::Box::new(_tmp2)})
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for CompoundPattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for CompoundPattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_compound_pattern_rec(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_compound_pattern_tuple(_ctxt, value) { return Ok(r); }
@ -505,9 +498,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for CompoundPattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for CompoundPattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
match self {
CompoundPattern::Rec {label: _tmp0, fields: _tmp1} => {
@ -662,7 +654,7 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_definition_or<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
fn parse_definition_or<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_13_OR { return Err(_support::ParseError::conformance_error("schema.Definition::or")); }
let _tmp1 = ();
@ -683,7 +675,7 @@ fn parse_definition_or<_Value: preserves::value::NestedValue + 'static>(_ctxt: &
})
}
fn parse_definition_and<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
fn parse_definition_and<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_14_AND { return Err(_support::ParseError::conformance_error("schema.Definition::and")); }
let _tmp1 = ();
@ -704,14 +696,13 @@ fn parse_definition_and<_Value: preserves::value::NestedValue + 'static>(_ctxt:
})
}
fn parse_definition_pattern<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
fn parse_definition_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
let _tmp0 = Pattern::parse(_ctxt, value)?;
Ok(Definition::Pattern(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Definition<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Definition<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_definition_or(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_definition_and(_ctxt, value) { return Ok(r); }
@ -720,9 +711,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Definition<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Definition<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
match self {
Definition::Or {pattern_0: _tmp0, pattern_1: _tmp1, pattern_n: _tmp2} => {
@ -784,9 +774,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Definitions<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Definitions<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -798,9 +787,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Definitions<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Definitions<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let Definitions(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (preserves::value::Value::symbol(_tmp1).wrap(), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -831,9 +819,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for DictionaryEntries<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for DictionaryEntries<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -845,9 +832,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for DictionaryEntries<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for DictionaryEntries<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let DictionaryEntries(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (_tmp1.clone(), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -888,20 +874,19 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_embedded_type_name_ref<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
fn parse_embedded_type_name_ref<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
let _tmp0 = Ref::parse(_ctxt, value)?;
Ok(EmbeddedTypeName::Ref(std::boxed::Box::new(_tmp0)))
}
fn parse_embedded_type_name_false<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
fn parse_embedded_type_name_false<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
if value != &_ctxt.LIT_15_FALSE { return Err(_support::ParseError::conformance_error("schema.EmbeddedTypeName::false")); }
let _tmp0 = ();
Ok(EmbeddedTypeName::False)
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for EmbeddedTypeName {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for EmbeddedTypeName {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_embedded_type_name_ref(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_embedded_type_name_false(_ctxt, value) { return Ok(r); }
@ -909,9 +894,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for EmbeddedTypeName {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for EmbeddedTypeName {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
match self {
EmbeddedTypeName::Ref(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -941,9 +925,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for ModulePath {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for ModulePath {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let _tmp1 = value.value().to_sequence()?;
let mut _tmp0 = std::vec::Vec::new();
@ -955,9 +938,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for ModulePath {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for ModulePath {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let ModulePath(_tmp0) = self;
{
@ -994,9 +976,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Modules<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Modules<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -1008,9 +989,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Modules<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Modules<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let Modules(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (_tmp1.unparse(_ctxt), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -1040,9 +1020,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for NamedAlternative<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for NamedAlternative<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_sequence()?;
if _tmp0.len() < 2 { return Err(_support::ParseError::conformance_error("schema.NamedAlternative")); }
@ -1052,9 +1031,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for NamedAlternative<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for NamedAlternative<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let NamedAlternative {variant_label: _tmp0, pattern: _tmp1} = self;
{
@ -1093,19 +1071,18 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_named_pattern_named<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedPattern<_Value>, _support::ParseError> {
fn parse_named_pattern_named<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedPattern<_Value>, _support::ParseError> {
let _tmp0 = Binding::parse(_ctxt, value)?;
Ok(NamedPattern::Named(std::boxed::Box::new(_tmp0)))
}
fn parse_named_pattern_anonymous<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedPattern<_Value>, _support::ParseError> {
fn parse_named_pattern_anonymous<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedPattern<_Value>, _support::ParseError> {
let _tmp0 = Pattern::parse(_ctxt, value)?;
Ok(NamedPattern::Anonymous(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for NamedPattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for NamedPattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_named_pattern_named(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_named_pattern_anonymous(_ctxt, value) { return Ok(r); }
@ -1113,9 +1090,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for NamedPattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for NamedPattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
match self {
NamedPattern::Named(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1151,19 +1127,18 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_named_simple_pattern_named<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedSimplePattern<_Value>, _support::ParseError> {
fn parse_named_simple_pattern_named<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedSimplePattern<_Value>, _support::ParseError> {
let _tmp0 = Binding::parse(_ctxt, value)?;
Ok(NamedSimplePattern::Named(std::boxed::Box::new(_tmp0)))
}
fn parse_named_simple_pattern_anonymous<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedSimplePattern<_Value>, _support::ParseError> {
fn parse_named_simple_pattern_anonymous<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedSimplePattern<_Value>, _support::ParseError> {
let _tmp0 = SimplePattern::parse(_ctxt, value)?;
Ok(NamedSimplePattern::Anonymous(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for NamedSimplePattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for NamedSimplePattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_named_simple_pattern_named(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_named_simple_pattern_anonymous(_ctxt, value) { return Ok(r); }
@ -1171,9 +1146,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for NamedSimplePattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for NamedSimplePattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
match self {
NamedSimplePattern::Named(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1209,19 +1183,18 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_pattern_simple_pattern<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Pattern<_Value>, _support::ParseError> {
fn parse_pattern_simple_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Pattern<_Value>, _support::ParseError> {
let _tmp0 = SimplePattern::parse(_ctxt, value)?;
Ok(Pattern::SimplePattern(std::boxed::Box::new(_tmp0)))
}
fn parse_pattern_compound_pattern<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Pattern<_Value>, _support::ParseError> {
fn parse_pattern_compound_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Pattern<_Value>, _support::ParseError> {
let _tmp0 = CompoundPattern::parse(_ctxt, value)?;
Ok(Pattern::CompoundPattern(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Pattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Pattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_pattern_simple_pattern(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_pattern_compound_pattern(_ctxt, value) { return Ok(r); }
@ -1229,9 +1202,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Pattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Pattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
match self {
Pattern::SimplePattern(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1273,9 +1245,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Ref {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Ref {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_16_REF { return Err(_support::ParseError::conformance_error("schema.Ref")); }
@ -1287,9 +1258,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Ref {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Ref {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let Ref {module: _tmp0, name: _tmp1} = self;
{
@ -1368,9 +1338,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Schema<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Schema<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_17_SCHEMA { return Err(_support::ParseError::conformance_error("schema.Schema")); }
@ -1387,9 +1356,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Schema<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Schema<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let Schema {definitions: _tmp0, embedded_type: _tmp1, version: _tmp2} = self;
{
@ -1590,13 +1558,13 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_simple_pattern_any<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_any<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
if value != &_ctxt.LIT_21_ANY { return Err(_support::ParseError::conformance_error("schema.SimplePattern::any")); }
let _tmp0 = ();
Ok(SimplePattern::Any)
}
fn parse_simple_pattern_atom<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_atom<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_22_ATOM { return Err(_support::ParseError::conformance_error("schema.SimplePattern::atom")); }
let _tmp1 = ();
@ -1605,7 +1573,7 @@ fn parse_simple_pattern_atom<_Value: preserves::value::NestedValue + 'static>(_c
Ok(SimplePattern::Atom {atom_kind: std::boxed::Box::new(_tmp2)})
}
fn parse_simple_pattern_embedded<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_embedded<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_23_EMBEDDED { return Err(_support::ParseError::conformance_error("schema.SimplePattern::embedded")); }
let _tmp1 = ();
@ -1614,7 +1582,7 @@ fn parse_simple_pattern_embedded<_Value: preserves::value::NestedValue + 'static
Ok(SimplePattern::Embedded {interface: std::boxed::Box::new(_tmp2)})
}
fn parse_simple_pattern_lit<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_lit<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_24_LIT { return Err(_support::ParseError::conformance_error("schema.SimplePattern::lit")); }
let _tmp1 = ();
@ -1623,7 +1591,7 @@ fn parse_simple_pattern_lit<_Value: preserves::value::NestedValue + 'static>(_ct
Ok(SimplePattern::Lit {value: _tmp2.clone()})
}
fn parse_simple_pattern_seqof<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_seqof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_25_SEQOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::seqof")); }
let _tmp1 = ();
@ -1632,7 +1600,7 @@ fn parse_simple_pattern_seqof<_Value: preserves::value::NestedValue + 'static>(_
Ok(SimplePattern::Seqof {pattern: std::boxed::Box::new(_tmp2)})
}
fn parse_simple_pattern_setof<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_setof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_26_SETOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::setof")); }
let _tmp1 = ();
@ -1641,7 +1609,7 @@ fn parse_simple_pattern_setof<_Value: preserves::value::NestedValue + 'static>(_
Ok(SimplePattern::Setof {pattern: std::boxed::Box::new(_tmp2)})
}
fn parse_simple_pattern_dictof<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_dictof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_27_DICTOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::dictof")); }
let _tmp1 = ();
@ -1651,14 +1619,13 @@ fn parse_simple_pattern_dictof<_Value: preserves::value::NestedValue + 'static>(
Ok(SimplePattern::Dictof {key: std::boxed::Box::new(_tmp2), value: std::boxed::Box::new(_tmp3)})
}
fn parse_simple_pattern_ref<_Value: preserves::value::NestedValue + 'static>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_ref<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = Ref::parse(_ctxt, value)?;
Ok(SimplePattern::Ref(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for SimplePattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for SimplePattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_simple_pattern_any(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_simple_pattern_atom(_ctxt, value) { return Ok(r); }
@ -1672,9 +1639,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for SimplePattern<_Value> {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for SimplePattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
match self {
SimplePattern::Any => (&_ctxt.LIT_21_ANY).clone(),
@ -1733,9 +1699,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> for Version {
type Language = crate::gen::Language<_Value>;
fn parse<'a, _LL: Into<&'a Self::Language>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Version {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _ctxt = _ctxt.into();
if value != &_ctxt.LIT_28_1 { return Err(_support::ParseError::conformance_error("schema.Version")); }
let _tmp0 = ();
@ -1743,9 +1708,8 @@ impl<_Value: preserves::value::NestedValue + 'static> _support::Parse<_Value> fo
}
}
impl<_Value: preserves::value::NestedValue + 'static> _support::Unparse<_Value> for Version {
type Language = crate::gen::Language<_Value>;
fn unparse<'a, _LL: Into<&'a Self::Language>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
impl<'a, _L: Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Version {
fn unparse(&self, _ctxt: _L) -> _Value {
let _ctxt = _ctxt.into();
let Version = self;
(&_ctxt.LIT_28_1).clone()

View File

@ -19,57 +19,37 @@ use std::sync::Arc;
use thiserror::Error;
pub trait Parse<Value: NestedValue>: Sized {
type Language;
fn parse<'a, LL: Into<&'a Self::Language>>(language: LL, value: &Value) ->
Result<Self, ParseError> where Self::Language: 'a;
pub trait Parse<L, Value: NestedValue>: Sized {
fn parse(language: L, value: &Value) -> Result<Self, ParseError>;
}
impl<Value: NestedValue> Parse<Value> for Value {
type Language = ();
fn parse<'a, LL: Into<&'a Self::Language>>(_language: LL, value: &Value) ->
Result<Self, ParseError> where Self::Language: 'a
{
impl<Value: NestedValue> Parse<(), Value> for Value {
fn parse(_language: (), value: &Value) -> Result<Self, ParseError> {
Ok(value.clone())
}
}
pub trait Unparse<Value: NestedValue> {
type Language;
fn unparse<'a, LL: Into<&'a Self::Language>>(&self, language: LL) ->
Value where Self::Language: 'a;
pub trait Unparse<L, Value: NestedValue> {
fn unparse(&self, language: L) -> Value;
}
impl<Value: NestedValue> Unparse<Value> for Value {
type Language = ();
fn unparse<'a, LL: Into<&'a Self::Language>>(&self, _language: LL) ->
Value where Self::Language: 'a
{
impl<Value: NestedValue> Unparse<(), Value> for Value {
fn unparse(&self, _language: ()) -> Value {
self.clone()
}
}
pub trait Codec<N: NestedValue, LL> {
fn parse<T: Parse<N>>(&self, value: &N) -> Result<T, ParseError>
where for<'a> &'a LL: Into<&'a T::Language>;
fn unparse<T: Unparse<N>>(&self, value: &T) -> N
where for<'a> &'a LL: Into<&'a T::Language>;
pub trait Codec<N: NestedValue> {
fn parse<'a, T: Parse<&'a Self, N>>(&'a self, value: &N) -> Result<T, ParseError>;
fn unparse<'a, T: Unparse<&'a Self, N>>(&'a self, value: &T) -> N;
}
impl<N: NestedValue + 'static, LL> Codec<N, LL> for LL {
fn parse<T: Parse<N>>(&self, value: &N) -> Result<T, ParseError>
where for<'a> &'a LL: Into<&'a T::Language>
{
impl<L, N: NestedValue> Codec<N> for L {
fn parse<'a, T: Parse<&'a L, N>>(&'a self, value: &N) -> Result<T, ParseError> {
T::parse(self, value)
}
fn unparse<T: Unparse<N>>(&self, value: &T) -> N
where for<'a> &'a LL: Into<&'a T::Language>
{
fn unparse<'a, T: Unparse<&'a L, N>>(&'a self, value: &T) -> N {
value.unparse(self)
}
}