diff --git a/src/de/decoder.rs b/src/de/decoder.rs index fddc399..df9756a 100644 --- a/src/de/decoder.rs +++ b/src/de/decoder.rs @@ -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`. /// diff --git a/src/de/mod.rs b/src/de/mod.rs index 14a4e32..95b28ba 100644 --- a/src/de/mod.rs +++ b/src/de/mod.rs @@ -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 {} -} diff --git a/src/enc/encoder.rs b/src/enc/encoder.rs index 8525b83..58a8605 100644 --- a/src/enc/encoder.rs +++ b/src/enc/encoder.rs @@ -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`. /// diff --git a/src/enc/mod.rs b/src/enc/mod.rs index e859ffb..bf989b1 100644 --- a/src/enc/mod.rs +++ b/src/enc/mod.rs @@ -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 {} -} diff --git a/src/lib.rs b/src/lib.rs index eca7d75..6b40163 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,6 +32,7 @@ extern crate alloc; extern crate std; mod features; +pub(crate) mod utils; pub(crate) mod varint; pub use features::*; diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 0000000..1433256 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,3 @@ +pub trait Sealed {} + +impl<'a, T> Sealed for &'a mut T where T: Sealed {}