mirror of https://git.sr.ht/~stygianentity/bincode
Joined the 2 Sealed traits into a single one
This commit is contained in:
parent
707d0d238f
commit
dae645f675
|
|
@ -1,9 +1,8 @@
|
|||
use super::{
|
||||
read::{BorrowReader, Reader},
|
||||
sealed::Sealed,
|
||||
BorrowDecoder, Decoder,
|
||||
};
|
||||
use crate::config::Config;
|
||||
use crate::{config::Config, utils::Sealed};
|
||||
|
||||
/// A Decoder that reads bytes from a given reader `R`.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
//! Decoder-based structs and traits.
|
||||
|
||||
use crate::{config::Config, error::DecodeError};
|
||||
|
||||
mod decoder;
|
||||
mod impl_core;
|
||||
mod impl_tuples;
|
||||
mod impls;
|
||||
|
||||
pub mod read;
|
||||
pub use self::decoder::DecoderImpl;
|
||||
use self::read::{BorrowReader, Reader};
|
||||
use crate::{config::Config, error::DecodeError, utils::Sealed};
|
||||
|
||||
pub mod read;
|
||||
|
||||
pub use self::decoder::DecoderImpl;
|
||||
|
||||
/// Trait that makes a type able to be decoded, akin to serde's `DeserializeOwned` trait.
|
||||
///
|
||||
|
|
@ -36,7 +37,7 @@ impl<'de, T: Decode> BorrowDecode<'de> for T {
|
|||
}
|
||||
|
||||
/// Any source that can decode basic types. This type is most notably implemented for [Decoder].
|
||||
pub trait Decoder: sealed::Sealed {
|
||||
pub trait Decoder: Sealed {
|
||||
/// The concrete [Reader] type
|
||||
type R: Reader;
|
||||
|
||||
|
|
@ -88,9 +89,3 @@ where
|
|||
T::borrow_reader(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod sealed {
|
||||
pub trait Sealed {}
|
||||
|
||||
impl<'a, T> Sealed for &'a mut T where T: Sealed {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Contains
|
||||
|
||||
use super::{sealed::Sealed, write::Writer, Encoder};
|
||||
use crate::config::Config;
|
||||
use super::{write::Writer, Encoder};
|
||||
use crate::{config::Config, utils::Sealed};
|
||||
|
||||
/// An Encoder that writes bytes into a given writer `W`.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ mod encoder;
|
|||
mod impl_tuples;
|
||||
mod impls;
|
||||
|
||||
use crate::{config::Config, error::EncodeError};
|
||||
use self::write::Writer;
|
||||
use crate::{config::Config, error::EncodeError, utils::Sealed};
|
||||
|
||||
pub mod write;
|
||||
|
||||
pub use self::encoder::EncoderImpl;
|
||||
use self::write::Writer;
|
||||
|
||||
/// Any source that can encode types. This type is most notably implemented for [Encoder].
|
||||
///
|
||||
|
|
@ -20,7 +20,7 @@ pub trait Encode {
|
|||
}
|
||||
|
||||
/// Helper trait to encode basic types into.
|
||||
pub trait Encoder: sealed::Sealed {
|
||||
pub trait Encoder: Sealed {
|
||||
/// The concrete [Writer] type
|
||||
type W: Writer;
|
||||
|
||||
|
|
@ -50,9 +50,3 @@ where
|
|||
T::config(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod sealed {
|
||||
pub trait Sealed {}
|
||||
|
||||
impl<'a, T> Sealed for &'a mut T where T: Sealed {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ extern crate alloc;
|
|||
extern crate std;
|
||||
|
||||
mod features;
|
||||
pub(crate) mod utils;
|
||||
pub(crate) mod varint;
|
||||
|
||||
pub use features::*;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
pub trait Sealed {}
|
||||
|
||||
impl<'a, T> Sealed for &'a mut T where T: Sealed {}
|
||||
Loading…
Reference in New Issue