Adjust quantification for Deserialize trait

This commit is contained in:
Tony Garnock-Jones 2022-10-24 14:28:30 +02:00
parent 703d5ac602
commit be7b8e6477
6 changed files with 49 additions and 49 deletions

View File

@ -9,11 +9,11 @@ repository = "https://gitlab.com/preserves/preserves"
license = "Apache-2.0"
[build-dependencies]
preserves-schema = { path = "../preserves-schema", version = "^2.5.0"}
preserves-schema = { path = "../preserves-schema", version = "^3.0.0-rc1"}
[dependencies]
preserves = { path = "../preserves", version = "^2.4.0"}
preserves-schema = { path = "../preserves-schema", version = "^2.5.0"}
preserves-schema = { path = "../preserves-schema", version = "^3.0.0-rc1"}
num = "0.4"
regex = "1.5"

View File

@ -1,6 +1,6 @@
[package]
name = "preserves-schema"
version = "2.5.0"
version = "3.0.0-rc1"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
description = "Implementation of Preserves Schema code generation and support for Rust."

View File

@ -141,13 +141,13 @@ pub fn gen_definition_reader(m: &mut ModuleContext, n: &str, d: &Definition) {
}
item(seq![
"impl", anglebrackets![
"'de",
seq![ctxt.m.any_type(), ": preserves::value::NestedValue"],
seq!["R: _support::Reader<'de, ", ctxt.m.any_type(), ">"]], " ",
"_support::Deserialize", anglebrackets!["'de", ctxt.m.any_type(), "R"], " ",
"for ", names::render_constructor(n), ty.generic_arg(ctxt.m), " ", codeblock![
seq!["fn deserialize(r: &mut R) -> ",
"impl", anglebrackets![seq![ctxt.m.any_type(), ": preserves::value::NestedValue"]],
" _support::Deserialize", anglebrackets![ctxt.m.any_type()], " for ",
names::render_constructor(n), ty.generic_arg(ctxt.m), " ", codeblock![
seq!["fn deserialize",
anglebrackets!["'de",
seq!["R: _support::Reader<'de, ", ctxt.m.any_type(), ">"]],
"(r: &mut R) -> ",
"std::result::Result<Self, _support::ParseError> ",
codeblock(body)]]])
});

View File

@ -107,8 +107,8 @@ fn read_atom_kind_symbol<'de, _Value: preserves::value::NestedValue, R: _support
Ok(AtomKind::Symbol)
}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for AtomKind {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for AtomKind {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_atom_kind_boolean(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_atom_kind_float(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -236,8 +236,8 @@ pub struct Binding<_Value: preserves::value::NestedValue = preserves::value::IOV
impl<_Value: preserves::value::NestedValue> preserves::value::Domain for Binding<_Value> {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Binding<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Binding<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_record(None)?;
let mut _tmp0 = _support::B::Type::default();
_tmp0.shift(Some(_support::B::Item::RecordLabel));
@ -300,8 +300,8 @@ pub struct Bundle<_Value: preserves::value::NestedValue = preserves::value::IOVa
impl<_Value: preserves::value::NestedValue> preserves::value::Domain for Bundle<_Value> {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Bundle<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Bundle<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_record(None)?;
let mut _tmp0 = _support::B::Type::default();
_tmp0.shift(Some(_support::B::Item::RecordLabel));
@ -476,8 +476,8 @@ fn read_compound_pattern_dict<'de, _Value: preserves::value::NestedValue, R: _su
Ok(CompoundPattern::Dict {entries: std::boxed::Box::new(_tmp2)})
}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for CompoundPattern<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for CompoundPattern<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_compound_pattern_rec(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_compound_pattern_tuple(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -716,8 +716,8 @@ fn read_definition_pattern<'de, _Value: preserves::value::NestedValue, R: _suppo
Ok(Definition::Pattern(std::boxed::Box::new(_tmp0)))
}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Definition<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Definition<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_definition_or(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_definition_and(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -845,8 +845,8 @@ pub struct Definitions<_Value: preserves::value::NestedValue = preserves::value:
impl<_Value: preserves::value::NestedValue> preserves::value::Domain for Definitions<_Value> {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Definitions<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Definitions<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_dictionary()?;
let mut _tmp2 = _support::B::Type::default();
let mut _tmp1 = preserves::value::Map::new();
@ -896,8 +896,8 @@ pub struct DictionaryEntries<_Value: preserves::value::NestedValue = preserves::
impl<_Value: preserves::value::NestedValue> preserves::value::Domain for DictionaryEntries<_Value> {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for DictionaryEntries<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for DictionaryEntries<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_dictionary()?;
let mut _tmp2 = _support::B::Type::default();
let mut _tmp1 = preserves::value::Map::new();
@ -967,8 +967,8 @@ fn read_embedded_type_name_false<'de, _Value: preserves::value::NestedValue, R:
Ok(EmbeddedTypeName::False)
}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for EmbeddedTypeName {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for EmbeddedTypeName {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_embedded_type_name_ref(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_embedded_type_name_false(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -1025,8 +1025,8 @@ pub struct ModulePath(pub std::vec::Vec<std::string::String>);
impl preserves::value::Domain for ModulePath {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for ModulePath {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for ModulePath {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_sequence()?;
let mut _tmp2 = _support::B::Type::default();
let mut _tmp1 = std::vec::Vec::new();
@ -1079,8 +1079,8 @@ pub struct Modules<_Value: preserves::value::NestedValue = preserves::value::IOV
impl<_Value: preserves::value::NestedValue> preserves::value::Domain for Modules<_Value> {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Modules<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Modules<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_dictionary()?;
let mut _tmp2 = _support::B::Type::default();
let mut _tmp1 = preserves::value::Map::new();
@ -1133,8 +1133,8 @@ pub struct NamedAlternative<_Value: preserves::value::NestedValue = preserves::v
impl<_Value: preserves::value::NestedValue> preserves::value::Domain for NamedAlternative<_Value> {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for NamedAlternative<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for NamedAlternative<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_sequence()?;
let mut _tmp0 = _support::B::Type::default();
_tmp0.shift(Some(_support::B::Item::SequenceValue));
@ -1196,8 +1196,8 @@ fn read_named_pattern_anonymous<'de, _Value: preserves::value::NestedValue, R: _
Ok(NamedPattern::Anonymous(std::boxed::Box::new(_tmp0)))
}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for NamedPattern<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for NamedPattern<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_named_pattern_named(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_named_pattern_anonymous(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -1266,8 +1266,8 @@ fn read_named_simple_pattern_anonymous<'de, _Value: preserves::value::NestedValu
Ok(NamedSimplePattern::Anonymous(std::boxed::Box::new(_tmp0)))
}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for NamedSimplePattern<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for NamedSimplePattern<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_named_simple_pattern_named(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_named_simple_pattern_anonymous(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -1336,8 +1336,8 @@ fn read_pattern_compound_pattern<'de, _Value: preserves::value::NestedValue, R:
Ok(Pattern::CompoundPattern(std::boxed::Box::new(_tmp0)))
}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Pattern<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Pattern<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_pattern_simple_pattern(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_pattern_compound_pattern(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -1396,8 +1396,8 @@ pub struct Ref {
impl preserves::value::Domain for Ref {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Ref {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Ref {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_record(None)?;
let mut _tmp0 = _support::B::Type::default();
_tmp0.shift(Some(_support::B::Item::RecordLabel));
@ -1462,8 +1462,8 @@ pub struct Schema<_Value: preserves::value::NestedValue = preserves::value::IOVa
impl<_Value: preserves::value::NestedValue> preserves::value::Domain for Schema<_Value> {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Schema<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Schema<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
r.open_record(None)?;
let mut _tmp0 = _support::B::Type::default();
_tmp0.shift(Some(_support::B::Item::RecordLabel));
@ -1748,8 +1748,8 @@ fn read_simple_pattern_ref<'de, _Value: preserves::value::NestedValue, R: _suppo
Ok(SimplePattern::Ref(std::boxed::Box::new(_tmp0)))
}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for SimplePattern<_Value> {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for SimplePattern<_Value> {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_simple_pattern_any(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_simple_pattern_atom(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -1928,8 +1928,8 @@ pub struct Version;
impl preserves::value::Domain for Version {}
impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>> _support::Deserialize<'de, _Value, R> for Version {
fn deserialize(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for Version {
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
match r.next_token(true)? {
preserves::value::Token::Atom(v) => match v.value() {
preserves::value::Value::SignedInteger(w) if *w == (1).into() => {}

View File

@ -59,11 +59,11 @@ impl<L, N: NestedValue> Codec<N> for L {
}
}
pub trait Deserialize<'de, N: NestedValue, R: Reader<'de, N>>
pub trait Deserialize<N: NestedValue>
where
Self: Sized
{
fn deserialize(r: &mut R) -> Result<Self, ParseError>;
fn deserialize<'de, R: Reader<'de, N>>(r: &mut R) -> Result<Self, ParseError>;
}
pub fn decode_lit<N: NestedValue>(bs: &[u8]) -> io::Result<N> {

View File

@ -11,7 +11,7 @@ license = "Apache-2.0"
[dependencies]
preserves = { path = "../preserves", version = "^2.4.0"}
preserves-path = { path = "../preserves-path", version = "^3.2.0"}
preserves-schema = { path = "../preserves-schema", version = "^2.5.0"}
preserves-schema = { path = "../preserves-schema", version = "^3.0.0-rc1"}
bytes = "1.0"
clap = "=3.0.0-beta.2"