Crates.io | best_skn_utils |
lib.rs | best_skn_utils |
version | 1.2.3 |
source | src |
created_at | 2024-06-09 10:23:50.488482 |
updated_at | 2024-08-17 17:34:24.821634 |
description | A Simple Utility Library For Rust |
homepage | |
repository | https://github.com/skn437/skn-rust-utils |
max_upload_size | |
id | 1266299 |
size | 17,981 |
Rust
env
, execution
, stdio
, random
& args
env
Module:init_config
function takes genericrustenv.toml
from which you can get data after invoking the functionrustenv.toml
must be placed in the root directory where Cargo.toml
file isUsage
section to get an example of how to use itexecution
Moduleexecute_command
function can run any command in the terminal
gnome_execute_command
function can open a new gnome terminal and executes commands in it
;
Usage
section to get an example of how to use itstdio
Moduleread_line
function returns String if it successfully reads the input else returns ErrorUsage
section to get an example of how to use itrandom
Modulegen_random_number
function takes two parameters to set a range. One is low
and the other one is high
Integer
or Float
low
and high
must be of same type i.e. you cannot set a range of say from 1 to 10.1high
is inclusive i.e. a range of 1 and 10 will mean the range includes from 1 to 10Usage
section to get an example of how to use itargs
Moduleget_args
function returns a collection as a vector of StringUsage
section to get an example of how to use it
cargo add best_skn_utils
use best_skn_utils::{env, execution, stdio, random, args};
env
module, you can use like thisrustenv.toml
file contains the data like this[author] name = "SKN" email = "skn437physx@gmail.com"
use best_skn_utils::env::init_config; use serde::Deserialize; #[derive(Debug, Deserialize)] struct Author { name: String, email: String, } impl Author { fn new() -> Self { Self { name: String::new(), email: String::new(), } } } #[derive(Debug, Deserialize)] struct ConfigData { author: Author, } impl ConfigData { fn new() -> Self { let config = init_config::<Self>(); match config { | Ok(value) => value, | Err(e) => { println!("Error: {}", e); Self { author: Author::new(), } } } } } let config_data: ConfigData = ConfigData::new(); println!("Name: {}, Email: {}", config_data.author.name, config_data.author.email);
execution
module, you can use like thisuse best_skn_utils::execution::{execute_command, gnome_execute_command}; execute_command("cargo", &["doc", "--open"]); gnome_execute_command("printf 'Hello SKN! \n'; printf 'Build was successful! ✅ \n'; read -n 1 KEY");
stdio
module, you can use like thisuse best_skn_utils::stdio::read_line; use std::io::Error; let input: Result<String, Error> = read_line("Write your name:"); match input { | Ok(value) => println!("Your name: {}", value), | Err(e) => println!("Error: {}", e), }
random
module, you can use like thisuse best_skn_utils::random::gen_random_number; let num1: i32 = gen_random_number(1, 10); let num2: f64 = gen_random_number(1.5, 7.5);
args
module, you can use like thisuse best_skn_utils::args::get_args; let args: Vec<String> = get_args(); println!("{:?}", args);
Tanjila Hasan Trina
: The long lost love of my life. The course of nature separated us from our paths and put us in separate places far away from each other. But no matter how separated we are right now, each and every moment of mine is only dedicated to you. We may not see each other in this lifetime as it seems but I will find you again in the next life. I just want to say: 世界は残酷だ それでも君を愛すよ
My Parents
: The greatest treasures of my life ever.
Copyright (C) 2024 SKN Shukhan
Licensed under the MIT License