Skip to content

Commit

Permalink
Add more warnings to apply buffering on docs of affected functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanBrouwer committed Jan 28, 2025
1 parent 65bbd1a commit 8c2d800
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ where
/// Create a JSON deserializer from one of the possible serde_json input
/// sources.
///
/// When reading from a source against which short reads are not efficient, such
/// as a [`File`], you will want to apply your own buffering because serde_json
/// will not buffer the input. See [`std::io::BufReader`].
///
/// Typically it is more convenient to use one of these methods instead:
///
/// - Deserializer::from_str
/// - Deserializer::from_slice
/// - Deserializer::from_reader
///
/// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html
pub fn new(read: R) -> Self {
Deserializer {
read,
Expand Down
6 changes: 6 additions & 0 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ where
R: io::Read,
{
/// Create a JSON input source to read from a std::io input stream.
///
/// When reading from a source against which short reads are not efficient, such
/// as a [`File`], you will want to apply your own buffering because serde_json
/// will not buffer the input. See [`std::io::BufReader`].
///
/// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html
pub fn new(reader: R) -> Self {
IoRead {
iter: LineColIterator::new(reader.bytes()),
Expand Down

0 comments on commit 8c2d800

Please sign in to comment.