Repository: jamesmunns/postcard (language: rust)

Issue:
Can't create IOReader
I am trying to read from std::io::Read using CRC. As this feature in not standard I am trying to use Flavors.
However,  I can't create an IOReader as its new() constructor is a private associated function, and if I try to crate the struct directly I can't because I need a SlidingBuffer, which is a private struct.
There is a reason why this is the case or am I missing something?


Discussion / hints:
Hi @giacomocaironi, I'm not too familiar with the IOReader, maybe @xgroleau has an idea?
Hey @giacomocaironi and @jamesmunns I don't see the reason why I've put IOReader `new` as private..... Probably overlooked it since I did not compose them with other flavors for my usecase.
I think we could just put the `new`from IOReader and `EIOReader` as public which would allow the user to compose the flavors as he see fit. 

Fix patch:
diff --git a/source/postcard/src/de/flavors.rs b/source/postcard/src/de/flavors.rs
index 844fd00..6333ed9 100644
--- a/source/postcard/src/de/flavors.rs
+++ b/source/postcard/src/de/flavors.rs
@@ -261,7 +261,10 @@ pub mod io {
         where
             T: crate::eio::Read,
         {
-            pub(crate) fn new(reader: T, buff: &'de mut [u8]) -> Self {
+            /// Create a new [`EIOReader`] from a reader and a buffer.
+            ///
+            /// `buff` must have enough space to hold all data read during the deserialisation.
+            pub fn new(reader: T, buff: &'de mut [u8]) -> Self {
                 Self {
                     reader,
                     buff: SlidingBuffer::new(buff),
@@ -328,7 +331,10 @@ pub mod io {
         where
             T: std::io::Read,
         {
-            pub(crate) fn new(reader: T, buff: &'de mut [u8]) -> Self {
+            /// Create a new [`IOReader`] from a reader and a buffer.
+            ///
+            /// `buff` must have enough space to hold all data read during the deserialisation.
+            pub fn new(reader: T, buff: &'de mut [u8]) -> Self {
                 Self {
                     reader,
                     buff: SlidingBuffer::new(buff),


Test patch: