use core::marker;
#[cfg(feature = "alloc")]
use crate::alloc::Global;
use crate::mode::Binary;
use crate::options;
use crate::{Context, Decode, Encode, IntoReader, IntoWriter, Options};
#[cfg(feature = "alloc")]
use super::error::Error;
use crate::storage::de::StorageDecoder;
use crate::storage::en::StorageEncoder;
pub const OPTIONS: Options = options::new().fixed().native_byte_order().build();
#[allow(unused)]
const DEFAULT: Encoding = Encoding::new();
crate::macros::bare_encoding!(Binary, DEFAULT, packed, IntoReader, IntoWriter);
pub struct Encoding<const OPT: Options = OPTIONS, M = Binary>
where
M: 'static,
{
_marker: marker::PhantomData<M>,
}
impl Default for Encoding<OPTIONS, Binary> {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl Encoding<OPTIONS, Binary> {
pub const fn new() -> Self {
Encoding {
_marker: marker::PhantomData,
}
}
}
impl<const OPT: Options, M> Encoding<OPT, M>
where
M: 'static,
{
pub const fn with_mode<T>(self) -> Encoding<OPT, T> {
Encoding {
_marker: marker::PhantomData,
}
}
pub const fn with_options<const U: Options>(self) -> Encoding<U, M> {
Encoding {
_marker: marker::PhantomData,
}
}
crate::macros::encoding_impls!(
M,
packed,
StorageEncoder::<OPT, true, _, _, M>::new,
StorageDecoder::<OPT, true, _, _, M>::new,
IntoReader::into_reader,
IntoWriter::into_writer,
);
}
impl<const OPT: Options, M> Clone for Encoding<OPT, M> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<const OPT: Options, M> Copy for Encoding<OPT, M> {}