diff --git a/src/features/impl_alloc.rs b/src/features/impl_alloc.rs index b770a3c..c31bf18 100644 --- a/src/features/impl_alloc.rs +++ b/src/features/impl_alloc.rs @@ -13,16 +13,18 @@ impl enc::write::Writer for VecWriter { } } +/// Encode the given value into a `Vec`. pub fn encode_to_vec(val: E) -> Result, error::EncodeError> { encode_to_vec_with_config(val, config::Default) } +/// Encode the given value into a `Vec` with the given `Config`. See the [config] module for more information. pub fn encode_to_vec_with_config( val: E, - _config: C, + config: C, ) -> Result, error::EncodeError> { let writer = VecWriter::default(); - let mut encoder = enc::Encoder::<_, C>::new(writer); + let mut encoder = enc::Encoder::<_, C>::new(writer, config); val.encode(&mut encoder)?; Ok(encoder.into_writer().inner) } diff --git a/src/features/impl_std.rs b/src/features/impl_std.rs index 0cdca00..9bfde7c 100644 --- a/src/features/impl_std.rs +++ b/src/features/impl_std.rs @@ -5,10 +5,14 @@ use crate::{ error::{DecodeError, EncodeError}, }; +/// Decode type `D` from the given reader. The reader can be any type that implements `std::io::Read`, e.g. `std::fs::File`. pub fn decode_from(src: &mut R) -> Result { decode_from_with_config(src, config::Default) } +/// Decode type `D` from the given reader with the given `Config`. The reader can be any type that implements `std::io::Read`, e.g. `std::fs::File`. +/// +/// See the [config] module for more information about config options. pub fn decode_from_with_config( src: &mut R, _config: C, @@ -27,6 +31,7 @@ impl<'storage, R: std::io::Read> Reader<'storage> for R { } } +/// Encode the given value into any type that implements `std::io::Write`, e.g. `std::fs::File`. pub fn encode_into_write( val: E, dst: &mut W, @@ -34,16 +39,17 @@ pub fn encode_into_write( encode_into_write_with_config(val, dst, config::Default) } +/// Encode the given value into any type that implements `std::io::Write`, e.g. `std::fs::File`, with the given `Config`. See the [config] module for more information. pub fn encode_into_write_with_config( val: E, dst: &mut W, - _config: C, + config: C, ) -> Result { let writer = IoWriter { writer: dst, bytes_written: 0, }; - let mut encoder = Encoder::<_, C>::new(writer); + let mut encoder = Encoder::<_, C>::new(writer, config); val.encode(&mut encoder)?; Ok(encoder.into_writer().bytes_written) }