#[doc(hidden)] pub mod decode;
#[doc(hidden)] pub mod encode;
#[doc(hidden)] pub mod format;
#[doc(hidden)] pub mod future;
#[doc(hidden)] pub mod collection;
#[doc(hidden)] pub mod intrinsic;
#[doc(hidden)] pub mod primitive;
#[doc(hidden)] pub mod wrapper;
pub mod internal;
use core::future::Future;
use crate::io;
#[doc(inline)]
pub use self::{
decode::{
Decode,
PollDecodeStatus,
StartDecodeStatus,
},
encode::{
Encode,
PollEncodeStatus,
StartEncodeStatus,
},
format::{
Format,
FormatDecode,
FormatDeserialize,
FormatEncode,
FormatSerialize
},
future::{
deserialize_exact::DeserializeExact,
serialize_all::SerializeAll,
}
};
pub trait Encodable
{
type Encoder<F>: Encode<Data=Self, Format=F>
where
F: FormatEncode,
;
}
pub trait Decodable: Sized
{
type Decoder<F>: Decode<Data=Self, Format=F>
where
F: FormatDecode,
;
}
pub trait AsyncSerialize: Encodable
{
type Future<'w, F, W>: Future<Output=Result<(), F::Error>> + Unpin
where
Self: 'w,
F: 'w + FormatSerialize,
W: 'w + io::AsyncWrite + Unpin,
;
fn serialize<'w, F, W>(&'w self, format: &'w F, writer: &'w mut W) -> Self::Future<'w, F, W>
where
F: FormatSerialize,
W: io::AsyncWrite + Unpin,
;
}
pub trait AsyncDeserialize: Decodable
{
type Future<'r, F, R>: Future<Output=Result<Self, F::Error>> + Unpin
where
F: 'r + FormatDeserialize,
R: 'r + io::AsyncBufRead + Unpin,
;
fn deserialize<'r, F, R>(format: &'r F, reader: &'r mut R) -> Self::Future<'r, F, R>
where
F: FormatDeserialize,
R: io::AsyncBufRead + Unpin,
;
}
pub trait AsyncSerialization: AsyncSerialize + AsyncDeserialize {}
impl<T> AsyncSerialization for T where T: AsyncSerialize + AsyncDeserialize {}