Add contraints to {Serializer,Deserializer}Acceptor

This allows the user to retreive concrete types from the
serializer & deserializer output.
This commit is contained in:
jean-airoldie 2019-11-05 20:24:50 -05:00 committed by Josh Matthews
parent 237e6852e9
commit e2d8742743
1 changed files with 6 additions and 2 deletions

View File

@ -51,7 +51,9 @@ pub trait DeserializerAcceptor<'a> {
/// The return type for the accept method
type Output;
/// Accept a serde::Deserializer and do whatever you want with it.
fn accept<T: serde::Deserializer<'a>>(self, T) -> Self::Output;
fn accept<T>(self, T) -> Self::Output
where
T: serde::Deserializer<'a, Error = Error>;
}
/// An object that implements this trait can be passed a
@ -63,7 +65,9 @@ pub trait SerializerAcceptor {
/// The return type for the accept method
type Output;
/// Accept a serde::Serializer and do whatever you want with it.
fn accept<T: serde::Serializer>(self, T) -> Self::Output;
fn accept<T>(self, T) -> Self::Output
where
T: serde::Serializer<Ok = (), Error = Error>;
}
/// Get a default configuration object.