added cli_pipeline doc-comms

pull/19/head
prplV 2024-12-23 09:44:53 +03:00
parent 7be46d4373
commit 97bc91ffcd
1 changed files with 39 additions and 1 deletions

View File

@ -6,7 +6,19 @@ use std::{borrow::BorrowMut, net::{IpAddr, Ipv4Addr}};
// use std::io::BufReader; // use std::io::BufReader;
use tokio::io::{BufReader, AsyncWriteExt, AsyncBufReadExt}; use tokio::io::{BufReader, AsyncWriteExt, AsyncBufReadExt};
/// # Fn `init_cli_pipeline`
/// ## for catching all input requests from CLI
///
/// *input* : -
///
/// *output* : `anyhow::Result<()>` to wrap errors
///
/// *initiator* : fn `main`
///
/// *managing* : `TcpListener` object to handle requests
///
/// *depends on* : -
///
pub async fn init_cli_pipeline() -> DynResult<()> { pub async fn init_cli_pipeline() -> DynResult<()> {
return match init_listener().await { return match init_listener().await {
Some(list) => { Some(list) => {
@ -27,6 +39,19 @@ pub async fn init_cli_pipeline() -> DynResult<()> {
} }
} }
/// # Fn `init_listener`
/// ## for creating TCP-listener for communicating with CLI
///
/// *input* : -
///
/// *output* : `Some<TcpListener>` if port 7753 was opened | None if not
///
/// *initiator* : fn `init_cli_pipeline`
///
/// *managing* : `TcpListener` object to handle requests
///
/// *depends on* : `tokio::net::TcpListener`
///
async fn init_listener() -> Option<TcpListener> { async fn init_listener() -> Option<TcpListener> {
return match TcpListener::bind("127.0.0.1:7753").await { return match TcpListener::bind("127.0.0.1:7753").await {
Ok(listener) => { Ok(listener) => {
@ -40,6 +65,19 @@ async fn init_listener() -> Option<TcpListener> {
} }
} }
/// # Fn `process_connection`
/// ## for processing input CLI requests
///
/// *input* : mut stream: `TcpStream`
///
/// *output* : -
///
/// *initiator* : fn `init_cli_pipeline`
///
/// *managing* : mutable object of `TcpStream`
///
/// *depends on* : `tokio::net::TcpStream`
///
async fn process_connection(mut stream: TcpStream) { async fn process_connection(mut stream: TcpStream) {
// loop{ // loop{
// stream. // stream.