std_io_iterators/
lib.rs

1//! An iterator for `STDIN` and a wrapper for `STDOUT`. Allows easy piping, and
2//! graceful closing of application if pipe breaks
3//!
4//! *Project by [SnS Development](https://gitlab.com/SnSDev)*
5//!
6//! # Problem
7//!
8//! Using `STDIN` and `STDOUT` (piping in or piping out) is more complicated
9//! than is necessary.  The developer should be able to obtain an iterator for
10//! the data being piped in through `STDIN`, and should be able to easily pipe
11//! out through `STDOUT` any iterator of elements implementing the [std::fmt::Debug] trait.
12//!
13//! Also, if the `STDOUT` pipe is "broken" (i.e. the data being piped into
14//! exits), the iterator being piped out through `STDOUT` should be recoverable
15//! so the data can be re-directed. (See Warning in
16//! [`prelude::PipeOut::pipe_out`])
17//!
18//! # Solution
19//!
20//! - A struct [prelude::PipeInIterator] - An [Iterator] that abstracts the
21//!   process of piping in through `STDIN`
22//! - A trait [prelude::PipeOut] - Implemented on any [Iterator] over elements
23//!   that implement [std::fmt::Debug] (like [String]) that abstracts the
24//!   process of piping out through `STDOUT`
25//!
26//! # Example
27//!
28//! ```rust,no_run
29#![doc = include_str!("examples/demo.rs")]
30//! ```
31//!
32//! # How To: Update Documentation
33//!
34//! The documentation in this project is contained in the documentation comments
35//! throughout the code.  Such comments are then compiled into the final
36//! documentation for the project via `rustdoc` when the code is published.
37//!
38//! It is good practice to include a `README.md` file in root folder of the
39//! source code for displaying in the respective version management system.  In
40//! compliance with DRY principle:
41//!
42//! <blockquote>
43//! Every piece of knowledge must have a single, unambiguous, authoritative
44//! representation within a system
45//!
46//! - Src: [Don't repeat yourself - Wikipedia](https://en.wikipedia.org/wiki/Don't_repeat_yourself)
47//! </blockquote>
48//!
49//! and in-order to keep the file from getting out-of-sync with the
50//! documentation, I simply duplicate the root page of the documentation via the
51//! enclosed script.
52//!
53//! ## `update_documentation.sh` *Run in the root of project*
54//!
55//! ```bash
56#![doc = include_str!("update_documentation.sh")]
57//! ```
58#![warn(missing_docs)]
59#![warn(clippy::pedantic)]
60#![warn(clippy::str_to_string)]
61#![warn(clippy::string_to_string)]
62
63pub mod into_std_io_result;
64pub mod pipe_in_iterator;
65pub mod pipe_out;
66pub mod pipe_out_recovered_iterator;
67
68pub mod prelude {
69    //! Re-exports all components as one module that can be glob imported.
70
71    pub use crate::{
72        into_std_io_result::IntoStdIoResult,
73        pipe_in_iterator::PipeInIterator,
74        pipe_out::{PipeOut, WriteLineResult},
75        pipe_out_recovered_iterator::PipeOutRecoveredIterator,
76    };
77}